<?php
class OLM_Address
{
	static function SY_HK_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont($font, '', 10);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', '', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', '', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('helvetica', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('helvetica', '', 11);
		$pdf->MultiCell(37, 13, '<div style="line-height: 5px;">BY AIR MAIL</div><font face="cid0cs">航</font> PAR AVION <font face="cid0cs">空</font>', 1, 'C', 0, 0, '', '', true, 0, true, true, 13, 'M');
		$pdf->MultiCell(10, 13, "1", 1, 'C', 0, 0, '', '', true, 0, false, true, 13, 'M');
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(27, 13, "POSTAGE PAID\nHONG KONG\nPORT PATY", 1, 'C', 0, 0, '', '', true, 0, false, true, 13, 'M');
		$pdf->MultiCell(20, 13, "PERMIT\nNO\n4532", 1, 'C', 0, 1, '', '', true, 0, false, true, 13, 'M');
		$pdf->Ln(1);
		$pdf->SetFont('cid0cs', '', 9);
		$pdf->MultiCell(68, '', '报关单 <font face="helvetica">CUSTOMS DECLARATION</font>', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->SetFont('times', 'B', 11);
		$pdf->MultiCell(26, '', 'CN 22', 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 6);
		$pdf->MultiCell(58, '', '（本件得由海关开拆 <font face="helvetica">May be opened officially</font>）', 0, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->SetFont('helvetica', '', 6);
		$pdf->MultiCell(36, '', 'Pos 401G(3/05)', 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 8);
		$pdf->Ln(1);
		$pdf->MultiCell(48, '', 'Postal administration', 0, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(46, '', '<font face="cid0cs">重要</font> Important!', 0, 'R', 0, 1, 50, '', true, 0, true, true);
		$pdf->MultiCell(48, '', '<font face="cid0cs">香港邮政</font> HONGKONG POST', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(46, '', '<font face="cid0cs" size="6">请参阅背面说明</font><br><font size="6">See Instructions on the back</font>', 0, 'R', 0, 1, '', '', true, 0, true, true);
		$y = $pdf->GetY();
		$pdf->Line(3, $y, 97, $y, '');
		$pdf->Ln(1);
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(5, 0, '', 1, 'C', 0, 0, 4, '', true);
		$pdf->MultiCell(33, 0, '<font face="cid0cs">礼物</font> Gift', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(5, 0, '', 1, 'C', 0, 0, 40, '', true);
		$pdf->MultiCell(51, 0, '<font face="cid0cs">商用样本</font> Commercial sample', 0, 'L', 0, 1, '', '', true, 0, true, true);
		$y = $pdf->GetY();
		$pdf->Ln(2);
		$pdf->MultiCell(5, '', '', 1, 'C', 0, 0, 4, '', true);
		$pdf->MultiCell(35, '', '<font face="cid0cs">文件</font> Documents', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(5, '', '<font face="cid0cs">√</font>', 1, 'C', 0, 0, 40, '', true, 0, true, true);
		$pdf->MultiCell(23, '', '<font face="cid0cs">其他</font> Other', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->SetFont('cid0cs', '', 6);
		$pdf->MultiCell(30, '', '（在适当方格内划上“√”号）<br>（<font face="helvetica">Tick as appropriate</font>）', 0, 'R', 0, 1, 60, $y, true, 0, true, true);
		$pdf->Ln(1);
		$pdf->SetFont('cid0cs', '', 7);
		$pdf->MultiCell(52, '', '（1）内载物品详情及数量<br><font face="helvetica">Quantity and detailed description of contents</font>', 1, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(23, '', '（2）重量<br><font face="helvetica"> weight</font>（公斤kg）', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(19, '', '（3）价值<br><font face="helvetica"> value</font>', 1, 'C', 0, 1, '', '', true, 0, true, true);
		$pdf->SetFont('cid0cs', '', 8);
		$pdf->MultiCell(52, 8, '<font face="helvetica">' . $sales_order_item[0]['declared_name_en'] . '</font><br>（' . $sales_order_item[0]['declared_name_cn'] . '）', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(23, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
		$pdf->MultiCell(19, 8, sprintf('%.3f', $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
		$pdf->SetFont('cid0cs', '', 7);
		$pdf->MultiCell(52, 15, '只是用于商品<font face="helvetica"> For commercial items only</font><br>（4）协制编号及（5）物品原产地(如有)<br><font face="helvetica">if know, HS tariff number (4) and<br>country of origin of goods (5)</font>', 1, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(23, 15, '（6）总重量<br><font face="helvetica">Total weight</font><br>（公斤kg）', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(19, 15, '（7）总共价值<br><font face="helvetica">Total value</font>', 1, 'C', 0, 1, '', '', true, 0, true, true);
		$pdf->Ln(1);
		$pdf->MultiCell(94, '', "在下面签署，以证明此报关单上列资料全属正确，及此邮件并不载有任何法例或邮政规例或海关条例所禁寄的危险物品。本人地 姓名及地址已载于邮件上。", 0, 'L', 0, 1, '', '', true);
		$y = $pdf->GetY();
		$pdf->Line(3, $y + 1, 97, $y + 1, '');
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(94, '', "I, the undersigned,whose name and address are given on the item,ce rtify that the particulars given in this declaration are correct and that this item does not contain any dangerous atricle or articles Prohibited by legisiation or by postal or customs regulations.", 0, 'L', 0, 1, '', ($y + 2), true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function FT_R_HK_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont($font, '', 10);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', '', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', '', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('helvetica', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('helvetica', '', 11);
		$pdf->MultiCell(37, 13, '<div style="line-height: 5px;">BY AIR MAIL</div><font face="cid0cs">航</font> PAR AVION <font face="cid0cs">空</font>', 1, 'C', 0, 0, '', '', true, 0, true, true, 13, 'M');
		$pdf->MultiCell(10, 13, "1", 1, 'C', 0, 0, '', '', true, 0, false, true, 13, 'M');
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(27, 13, "POSTAGE PAID\nHONG KONG\nPORT PATY", 1, 'C', 0, 0, '', '', true, 0, false, true, 13, 'M');
		$pdf->MultiCell(20, 13, "PERMIT\nNO\n4532", 1, 'C', 0, 1, '', '', true, 0, false, true, 13, 'M');
		$pdf->Ln(1);
		$pdf->SetFont('cid0cs', '', 9);
		$pdf->MultiCell(68, '', '报关单 <font face="helvetica">CUSTOMS DECLARATION</font>', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->SetFont('times', 'B', 11);
		$pdf->MultiCell(26, '', 'CN 22', 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 6);
		$pdf->MultiCell(58, '', '（本件得由海关开拆 <font face="helvetica">May be opened officially</font>）', 0, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->SetFont('helvetica', '', 6);
		$pdf->MultiCell(36, '', 'Pos 401G(3/05)', 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 8);
		$pdf->Ln(1);
		$pdf->MultiCell(48, '', 'Postal administration', 0, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(46, '', '<font face="cid0cs">重要</font> Important!', 0, 'R', 0, 1, 50, '', true, 0, true, true);
		$pdf->MultiCell(48, '', '<font face="cid0cs">香港邮政</font> HONGKONG POST', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(46, '', '<font face="cid0cs" size="6">请参阅背面说明</font><br><font size="6">See Instructions on the back</font>', 0, 'R', 0, 1, '', '', true, 0, true, true);
		$y = $pdf->GetY();
		$pdf->Line(3, $y, 97, $y, '');
		$pdf->Ln(1);
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(5, 0, '', 1, 'C', 0, 0, 4, '', true);
		$pdf->MultiCell(33, 0, '<font face="cid0cs">礼物</font> Gift', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(5, 0, '', 1, 'C', 0, 0, 40, '', true);
		$pdf->MultiCell(51, 0, '<font face="cid0cs">商用样本</font> Commercial sample', 0, 'L', 0, 1, '', '', true, 0, true, true);
		$y = $pdf->GetY();
		$pdf->Ln(2);
		$pdf->MultiCell(5, '', '', 1, 'C', 0, 0, 4, '', true);
		$pdf->MultiCell(35, '', '<font face="cid0cs">文件</font> Documents', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(5, '', '<font face="cid0cs">√</font>', 1, 'C', 0, 0, 40, '', true, 0, true, true);
		$pdf->MultiCell(23, '', '<font face="cid0cs">其他</font> Other', 0, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->SetFont('cid0cs', '', 6);
		$pdf->MultiCell(30, '', '（在适当方格内划上“√”号）<br>（<font face="helvetica">Tick as appropriate</font>）', 0, 'R', 0, 1, 60, $y, true, 0, true, true);
		$pdf->Ln(1);
		$pdf->SetFont('cid0cs', '', 7);
		$pdf->MultiCell(52, '', '（1）内载物品详情及数量<br><font face="helvetica">Quantity and detailed description of contents</font>', 1, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(23, '', '（2）重量<br><font face="helvetica"> weight</font>（公斤kg）', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(19, '', '（3）价值<br><font face="helvetica"> value</font>', 1, 'C', 0, 1, '', '', true, 0, true, true);
		$pdf->SetFont('cid0cs', '', 8);
		$pdf->MultiCell(52, 8, '<font face="helvetica">' . $sales_order_item[0]['declared_name_en'] . '</font><br>（' . $sales_order_item[0]['declared_name_cn'] . '）', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(23, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
		$pdf->MultiCell(19, 8, sprintf('%.3f', $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
		$pdf->SetFont('cid0cs', '', 7);
		$pdf->MultiCell(52, 15, '只是用于商品<font face="helvetica"> For commercial items only</font><br>（4）协制编号及（5）物品原产地(如有)<br><font face="helvetica">if know, HS tariff number (4) and<br>country of origin of goods (5)</font>', 1, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(23, 15, '（6）总重量<br><font face="helvetica">Total weight</font><br>（公斤kg）', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(19, 15, '（7）总共价值<br><font face="helvetica">Total value</font>', 1, 'C', 0, 1, '', '', true, 0, true, true);
		$pdf->Ln(1);
		$pdf->MultiCell(94, '', "在下面签署，以证明此报关单上列资料全属正确，及此邮件并不载有任何法例或邮政规例或海关条例所禁寄的危险物品。本人地 姓名及地址已载于邮件上。", 0, 'L', 0, 1, '', '', true);
		$y = $pdf->GetY();
		$pdf->Line(3, $y + 1, 97, $y + 1, '');
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(94, '', "I, the undersigned,whose name and address are given on the item,ce rtify that the particulars given in this declaration are correct and that this item does not contain any dangerous atricle or articles Prohibited by legisiation or by postal or customs regulations.", 0, 'L', 0, 1, '', ($y + 2), true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function SFC_CH_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "To:";
		$address .= $sales_order['fullname'] . "\n";
		$address .= $sales_order['street1'] ? ($sales_order['street1'] . "\n") : '';
		$address .= $sales_order['street2'] ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . ',' . $sales_order['zip'] . "\n";
		$address .= $sales_order['country'] . "\n";
		$address .= $sales_order['phone'] ? ('Tel: ' . $sales_order['phone'] . "\n") : '';
		$address .= $sales_order['address_notes'] ? ('Notes: ' . $sales_order['address_notes']) : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$country = array(
			'B' => array('奥地利','保加利亚','加拿大','塞浦路斯','马耳他','新西兰','葡萄牙'),
			'C' => array('阿富汗','阿尔及利亚','安哥拉','安圭拉岛','安提瓜和巴布达','阿鲁巴岛','巴哈马','巴林','巴巴多斯','伯利兹城','贝宁','玻利维亚','博茨瓦纳','布基纳法索','布隆迪','喀麦隆','佛得角','开曼群岛','中非共和国','乍得','智利','哥伦比亚','科摩罗','哥斯达黎加','古巴','吉布提','多米尼加共和国','厄瓜多尔','萨尔瓦多','赤道几内亚','厄立特里亚','法属圭亚那','冈比亚','加纳','格林纳达','法属瓜德罗普岛','危地马拉','几内亚','圭亚那','海地','洪都拉斯','伊朗','伊拉克','牙买加','肯尼亚','科威特','黎巴嫩','莱索托','利比里亚','圣马丁','利比亚','马达加斯加','马拉维','马里','马提尼克岛','毛里求斯','蒙特塞拉特岛','摩洛哥','莫桑比克','纳米比亚','尼加拉瓜','尼日尔','尼日利亚','阿曼','巴勒斯坦','巴拿马','巴拉圭','秘鲁','波多黎各','卡塔尔','卢旺达','圣基茨和尼维斯','圣卢西亚岛','圣多美和普林西比','沙特阿拉伯','塞内加尔','塞舌尔','塞拉利昂','索马里','苏里南','斯威士兰','坦桑尼亚','多哥','特立尼达和多巴哥','突尼斯','特克斯和凯科斯群岛','乌干达','乌拉圭','委内瑞拉','英属维尔京群岛','美属维尔京群岛','也门','赞比亚','津巴布韦','南非','俄罗斯','阿根廷','巴西','埃及','科特迪瓦','苏丹','叙利亚','圣文森特和格林纳丁斯','俄罗斯联邦'),
			'S' => array('荷兰','捷克','爱沙尼亚','斯洛伐克','斯洛文尼亚','瑞典','匈牙利','法国','德国','丹麦','比利时','芬兰','西班牙','波兰')
		);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->MultiCell(94, 6, 'PRIORITY', 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		$pdf->SetFont('helvetica', 'B', 8);
		$pdf->MultiCell(47, 15, "If undeliverable,please\nreturn to: Exchange Office\nSPI HKG 00001688 8010\nZurich-Mulligen Switzerland", 1, 'L', 0, 0, '', '', true, 0, false, true, 15, 'M');
		$pdf->MultiCell(47, 15, "P.P.\nSwiss Post\nCH-8010 Zurich\nMulligen", 1, 'C', 0, 1, '', '', true, 0, false, true, 15, 'M');
		$pdf->SetFont($font, '', 10);
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(29, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(18, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', 'B', 12);
		$pdf->write1DBarcode($sales_order['lsp_number'] ? $sales_order['lsp_number'] : $sales_order['number'], 'C128', '', '', 60, 10, 0.4, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$acode = 'A';
		foreach ($country as $key => $c)
		{
			if (in_array($sales_order['country_cn'], $c))
			{
				$acode = $key;
				break;
			}
		}
		$pdf->MultiCell('', '', $acode . "\n" . 'SWBAM', 0, 'C', 0, 0, 70, $pdf->GetY());
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 8, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 9, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->SetFont('times', 'B', 9);
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 10, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(94, 22, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(94, 6, $sales_order['number'], 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function SFC_R_CH_Package($sales_order_id)
	{
		set_time_limit(0);
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "To: ";
		$address .= $sales_order['fullname'] . "\n";
		$address .= $sales_order['street1'] ? ($sales_order['street1'] . "\n") : '';
		$address .= $sales_order['street2'] ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . ',' . $sales_order['zip'] . "\n";
		$address .=  $sales_order['country'] . "\n";
		$address .= $sales_order['phone'] ? ('Tel: ' . $sales_order['phone'] . "\n") : '';
		$address .= $sales_order['address_notes'] ? ('Notes: ' . $sales_order['address_notes']) : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$country = array(
			'B' => array('奥地利','保加利亚','加拿大','塞浦路斯','马耳他','新西兰','葡萄牙'),
			'C' => array('阿富汗','阿尔及利亚','安哥拉','安圭拉岛','安提瓜和巴布达','阿鲁巴岛','巴哈马','巴林','巴巴多斯','伯利兹城','贝宁','玻利维亚','博茨瓦纳','布基纳法索','布隆迪','喀麦隆','佛得角','开曼群岛','中非共和国','乍得','智利','哥伦比亚','科摩罗','哥斯达黎加','古巴','吉布提','多米尼加共和国','厄瓜多尔','萨尔瓦多','赤道几内亚','厄立特里亚','法属圭亚那','冈比亚','加纳','格林纳达','法属瓜德罗普岛','危地马拉','几内亚','圭亚那','海地','洪都拉斯','伊朗','伊拉克','牙买加','肯尼亚','科威特','黎巴嫩','莱索托','利比里亚','圣马丁','利比亚','马达加斯加','马拉维','马里','马提尼克岛','毛里求斯','蒙特塞拉特岛','摩洛哥','莫桑比克','纳米比亚','尼加拉瓜','尼日尔','尼日利亚','阿曼','巴勒斯坦','巴拿马','巴拉圭','秘鲁','波多黎各','卡塔尔','卢旺达','圣基茨和尼维斯','圣卢西亚岛','圣多美和普林西比','沙特阿拉伯','塞内加尔','塞舌尔','塞拉利昂','索马里','苏里南','斯威士兰','坦桑尼亚','多哥','特立尼达和多巴哥','突尼斯','特克斯和凯科斯群岛','乌干达','乌拉圭','委内瑞拉','英属维尔京群岛','美属维尔京群岛','也门','赞比亚','津巴布韦','南非','俄罗斯','阿根廷','巴西','埃及','科特迪瓦','苏丹','叙利亚','圣文森特和格林纳丁斯','俄罗斯联邦'),
			'S' => array('荷兰','捷克','爱沙尼亚','斯洛伐克','斯洛文尼亚','瑞典','匈牙利','法国','德国','丹麦','比利时','芬兰','西班牙','波兰')
		);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->MultiCell(94, 6, 'PRIORITY', 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		$pdf->SetFont('helvetica', 'B', 8);
		$pdf->MultiCell(47, 15, "If undeliverable,please\nreturn to: Exchange Office\nSPI HKG 00001688 8010\nZurich-Mulligen Switzerland", 1, 'L', 0, 0, '', '', true, 0, false, true, 15, 'M');
		$pdf->MultiCell(47, 15, "P.P.\nSwiss Post\nCH-8010 Zurich\nMulligen", 1, 'C', 0, 1, '', '', true, 0, false, true, 15, 'M');
		$pdf->SetFont($font, '', 10);
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(29, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(18, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->SetFont('helvetica', 'B', 10);
		$acode = 'A';
		foreach ($country as $key => $c)
		{
			if (in_array($sales_order['country_cn'], $c))
			{
				$acode = $key;
				break;
			}
		}
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 8, 0.45, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->MultiCell('', 14, $acode . '&nbsp;&nbsp;<font size="20">R</font><div>SWBRAM</div>', 1, 'R', 0, 1, '', $pdf->GetY()-4, true, 0, true, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 8, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 9, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 10, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(94, 22, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(94, 6, $sales_order['number'], 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function SY_R_CH_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('droidsansfallback', 'B', 9);
		$pdf->MultiCell(36, 0, '客户ID: A5305', 0, 'L', 0, 1, '', '', true);
		$country = array(
			'A' => array('AD', 'AE', 'AT', 'AZ', 'BA', 'BE', 'BG', 'BO', 'BY', 'CY', 'CZ', 'DE', 'DK', 'EG', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IL', 'IS', 'JP', 'KR', 'LT', 'LU', 'LV', 'MA', 'ME', 'MK', 'MX', 'NL', 'PL', 'PT', 'RE', 'RO', 'RS', 'RW', 'SA', 'SE', 'SI', 'SK', 'TR', 'UA', 'US'),
			'B' => array('CA', 'NZ', 'ZA'),
			'C' => array('AU', 'RU', 'AR', 'BR', 'CH'),
			'D' => array('NO', 'IT')
		);
		foreach ($country as $key => $c)
		{
			if (in_array($sales_order['country_code'], $c))
			{
				$pdf->SetFont('freeserif', 'B', 12);
				$pdf->MultiCell(8, 0, $key, 0, 'C', 0, 0, 30, 15, true);
				break;
			}
		}
		$pdf->SetFont('freeserif', 'B', 6);
		$pdf->MultiCell(58, '', 'ECONOMY', 1, 'C', 0, 0, 39, 3, true);
		$pdf->Ln();
		$pdf->Image(Q::ini('custom_system/img_dir') . 'swisspost.png', '', '', 36, 8, 'png', '', '', true, 300, '', false, false, 1, false, false, false);
		$pdf->SetFont('freeserif', '', 6.5);
		$pdf->MultiCell(29, 15, "If undeliverable,\nplease return to:\nSPI HKG 0000 1688\n8010 Zurich Mulligen\nSwitzerland", 1, 'L', 0, 0, 39, '', true);
		$pdf->SetFont('freeserif', 'B', 7);
		$pdf->MultiCell(29, 15, "P.P.\nSwiss Post CH-8010\nZurich Mulligen", 1, 'C', 0, 0, 68, '', true);
		$pdf->Ln();
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$pdf->SetFont('freeserif', '', 12);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('droidsansfallback', 'B', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(29, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(18, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('droidsansfallback', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('droidsansfallback', 'B', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('freeserif', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('freeserif', 'B', 10);
		$pdf->MultiCell(58, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('freeserif', '', 8);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('freeserif', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('freeserif', '', 9);
		$pdf->MultiCell(94, 0, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "√", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(52, 8, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, "Value", 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('droidsansfallback', 'B', 9);
		$pdf->MultiCell(52, 10, $sales_order_item[0]['declared_name_en'] . "\n(" . $sales_order_item[0]['declared_name_cn'] . ')', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(52, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(21, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('droidsansfallback', '', 8);
		$pdf->MultiCell(94, 0, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(94, 0, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->SetFont('droidsansfallback', '', 10);
		$pdf->MultiCell(94, 0, $sales_order['number'], 1, 'C', 0, 1, '', '', true, 0, false, true, 0, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function SFC_DE_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "TO:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(25, 20, "PRODUCT:\nPACKET\nSTANDARD\n                      VOD", 1, 'L', 0, 0, '', '', true, 0, false, true, 20, 'M');
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(25, 20, "Wenn unzustellbar,\nzurück an:\nPostfach 2007\n36254 Niederaula", 1, 'L', 0, 0, '', '', true, 0, false, true, 20, 'M');
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(44, 6, "Deutsche Post", 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		$pdf->SetFont('times', '', 10);
		$pdf->MultiCell(44, 14, "Entgelt bezahlt\n605544 Frankfurt\n(2378)", 1, 'C', 0, 1, 53, '', true, 0, false, true, 14, 'M');
		$pdf->SetFont($font, '', 10);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', '', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 9, 0.45, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->Ln();
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(94, '', 'DEAM2', 0, 'R', 0, 1, '', '', true);		
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 8, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 9, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 10, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(94, 22, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.", 1, 'L', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(94, 12, '<table><tr><td width="90%">Date and Sender\'s signature:</td><td><font size="15">Mak</font></td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function SFC_R_DE_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/SFC/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card',
					'country.code as country_code',
					'shipping_method.name as shipping_method_name'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
					->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
					->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->SetFont('helvetica', '', 7);
				$pdf->MultiCell(94, 15, "Wenn unzustellbar,\nzurück an:\nPostfach 2007\n36254 Niederaula", 1, 'L', 0, 0, '', '', true);
				$pdf->SetFont('times', 'B', 8);
				$pdf->MultiCell(47, 0, "Deutsche Post", 1, 'C', 0, 0, 50, 3, true);
				$pdf->SetFont('helvetica', '', 6);
				$pdf->MultiCell(47, 10, "Entgelt bezahlt\n605544 Frankfurt\n(2378)", 1, 'C', 0, 0, 50, 6.8, false);
				$pdf->Ln();
				$address = "Ship to:\n";
				$address .= $sales_order['fullname'] . "\n";
				$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
				$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
				$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
				$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
				$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
				$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf->SetFont($font, '', 12);
				$country_code_y = $pdf->GetY();
				$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
				$pdf->SetFont('cid0cs', 'B', 10);
				$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
				$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
				$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
				foreach ($sales_order_item as $key => $soi)
				{
					$ln = $key % 2;
					$product = $soi['product_number'] . ' * ' . $soi['quantity'];
					$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
				}
				if (count($sales_order_item) % 2 == 1)
				{
					$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
				}
				$pdf->Ln(2);
				$pdf->SetFont('helvetica', 'B', 8);
				$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 94, 9, 0.45, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
				$pdf->Ln();
				$pdf->SetFont('times', 'B', 10);
				$pdf->MultiCell(82, 0, 'DERAM2', 0, 'R', 0, 1, '', '', true);				
				$pdf->SetFont('times', 'B', 12);
				$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
				$pdf->AddPage();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->SetFont('times', 'B', 9);
				$pdf->MultiCell(47, 10, "ZOLLINHALTSERKLÄRUNG\nDÉCLARATION EN DOUANE", 0, 'L', 0, 0, '', '', true, 0, false, true, 10, 'T');
				$pdf->SetFont('helvetica', '', 6);
				$pdf->MultiCell(32, 10, "Kann amtlich geöffnet werden\nPeut être ouvert d’office", 0, 'L', 0, 0, '', '', true, 0, false, true, 10, 'T');
				$pdf->SetFont('times', 'B', 15);
				$pdf->MultiCell(15, '', "CN22", 0, 'L', 0, 1, '', '', true);
				$pdf->SetFont('helvetica', '', 7);
				$pdf->MultiCell(32, 10, "Postverwaltung\nAdministration des postes", 0, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->SetFont('times', 'B', 10);
				$pdf->MultiCell(35, 10, "Deutsche Post", 0, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->Image(Q::ini('custom_system/img_dir') . 'depost.png', 58, 12, 6, 5, 'PNG', '', '', true, 300, '', false, false, 0, false, false, false);
				$pdf->SetFont('helvetica', '', 8);
				$pdf->MultiCell(29, 0, 'Wichtig! Important!<br><font size="6">Hinweise auf der Rückseite<br>Voir instructions au verso</font>', 0, 'R', 0, 1, '', '', true, 0, true, true, 10, 'T');
				$pdf->SetFont('cid0cs', '', 8);
				$pdf->MultiCell(6, 6, '√', 1, 'C', 0, 0, '', '', true, 0, false, true, 6, 'M');
				$pdf->SetFont('helvetica', '', 6);
				$pdf->MultiCell(15, 6, "Geschenk\nCadeau", 1, 'L', 0, 0, '', '', true, 0, false, true, 6, 'M');
				$pdf->MultiCell(6, 6, '', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(15, 6, "Dokumente\nDocuments", 1, 'L', 0, 0, '', '', true, 0, false, true, 6, 'M');
				$pdf->MultiCell(6, 6, '', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(25, 6, "Warenmuster\nEchantillon commercial", 1, 'L', 0, 0, '', '', true, 0, false, true, 6, 'M');
				$pdf->MultiCell(6, 6, '', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(15, 6, "Sonstige\nAutre", 1, 'L', 0, 1, '', '', true, 0, false, true, 6, 'M');
				$pdf->MultiCell(94, 5, "Bitte ein oder mehrere Kästchen ankreuzen. Coucher la ou les cases appropriées.", 1, 'L', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(47, 8, "Anzahl und detaillierte Beschreibung des Inhalts (1) Quantité et description detaillée du contenu", 1, 'L', 0, 0, '', '', true);
				$pdf->MultiCell(24, 8, "Gewicht (in kg) (2) Poids (en kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(23, 8, "Wert (3)\nValeur", 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
				$pdf->SetFont('helvetica', 'B', 8);
				$pdf->MultiCell(47, 0, $sales_order_item[0]['declared_name_en'] . ' (<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
				$pdf->MultiCell(24, 0, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(23, 0, 15, 1, 'C', 0, 1, '', '', true);
				$pdf->SetFont('helvetica', '', 6);
				$pdf->MultiCell(47, 16, "Nur für Handelswaren Pour les envois commerciaux seulement (Falls bekannt) Zolltarifnr. nach dem HS (4) und Ursprungsland per Waren (5) N° tarifaire du SH et pays d’origine des marchandi-ses (si connus)", 1, 'L', 0, 0, '', '', true, 0, false, true, 16, 'M');
				$pdf->MultiCell(24, 16, "Gesamtgewicht\n(in kg) (6)\nPoids total (en kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 16, 'M');
				$pdf->MultiCell(23, 16, "Gesamtwert (7)\nValeur totale", 1, 'C', 0, 1, '', '', true, 0, false, true, 16, 'M');
				$pdf->SetFont('helvetica', 'B', 8);
				$pdf->MultiCell(47, 0, 'PRC', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(24, 0, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(23, 0, 15, 1, 'C', 0, 1, '', '', true);
				$pdf->SetFont('helvetica', '', 6);
				$pdf->MultiCell(94, 25, "lch, der/die Unterzeichnende, dessen/deren Name und Adresse auf der Sendung angeführt sind, bestätige, dass die in der vorliegenden Zollinhaltserklärung angegebenen Daten korrekt sind und dass diese Sendung keine gefährlichen, gesetzlich oder auf Grund postalischer oder zollrechtlicher Regelungen verbotenen Gegenstände enthält. Ich übergebe insbesondere keine Güter, deren Versand, Beförderung oder Lagerung gemäß den AGB von Deutsche Post ausgeschlossen ist. Je, soussigné dont le nom et l’adresse figurent sur l’envoi, certifie que les renseignements donnés dans la présente déclaration sont exacts et que cet envoi ne contient aucun objet dangereux ou interdit par la législation ou la réglementation postale ou l’entreposage est exclu par les Conditions générales de Deutsche Post.\n", 1, 'L', 0, 1, '', '', true, 0, false, true, 25, 'M');
				$pdf->SetFont('helvetica', '', 6);
				$pdf->MultiCell(94, 5, 'Datum und Unterschrift des Absenders (8)/Date et signature de l’expéditeur: <br><table><tr><td><font size="8"><B>EN</B></font></td><td align="right"><font size="8"><B>SFC</B></font></td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true, true, 10, 'M');		
				$pdf->SetFont('helvetica', 'B', 9);
				$pdf->MultiCell(94, 0, $sales_order['number'], 1, 'C', 0, 1, '', '', true);
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function FT_Global_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(25, 0, '<font face="cid0cs">客户</font>ID: 13170', 0, 'C', 0, 1, '', '', true, 0, 1);
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf->SetFont($font, '', 12);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function FT_R_Global_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->MultiCell(25, 0, '<font face="cid0cs">客户</font>ID: 13170', 0, 'C', 0, 1, '', '', true, 0, 1);
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf->SetFont($font, '', 12);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', 'B', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function BY_IEUB($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/BY/value'))
		{
			set_time_limit(0);
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'weight, declared_name_cn, declared_name_en, declared_value', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
			$address = $sales_order['fullname'] . "\n";
			$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
			$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
			$address .= $sales_order['city'] . '' . $sales_order['state'] . ' ' . $sales_order['zip'] . "\n";
			$address .= $sales_order['country'] . "\n";
			$address .= ($sales_order['phone']) ? ($sales_order['phone'] . "\n") : '';
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$code = array(
				'1F' => array('000-069', '074-078', '080-087', '090-099', '105-109', '115', '117-299'),
				'1P' => array('103', '110-114', '116'),
				'1Q' => array('070-073', '079', '088-089'),
				'1R' => array('100-102', '104'),
				'3F' => array('400-433', '437-439', '450-459', '470-471', '475-477', '480', '483-485', '490-491', '493-497', '500-529', '533', '536', '540', '546-548', '550-609', '612', '617-619', '621', '624', '632', '635', '640-699', '740-758', '760-772', '785-787', '789-799'),
				'3P' => array('460-469', '472-474', '478-479'),
				'3Q' => array('498-499', '530-532', '534-535', '537-539', '541-545', '549', '610-611'),
				'3R' => array('759', '773-778'),
				'3U' => array('613-616', '620', '622-623', '625-631', '633-634', '636-639'),
				'3C' => array('434-436', '481-482', '486-489', '492'),
				'3D' => array('779-784', '788'),
				'3H' => array('440-449'),
				'4F' => array('813-843', '854', '856-858', '861-862', '864-899', '906', '909-918', '926-939'),
				'4P' => array('900-905', '907-908'),
			);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(2, 2, 2);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->SetFont('helvetica', 'B', 40);
			$pdf->MultiCell(17, 17, 'F', 1, 'C', 0, 1, '', '', true, 0, true, true, 17, 'M');
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 35, 1, 28, 9, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->Line(30, 11, 67, 11);
			$pdf->Image(Q::ini('custom_system/img_dir') . 'eub.png', 28, 12, 45, 7, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 9);
			$pdf->MultiCell(98, 4, 'From:                                        ePacket™', 0, 'L', 0, 1, '', '', true);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(23, 11, '  Airmail' . "\n" . '  Postage Paid' . "\n" . '  China Post', 1, 'L', 0, 1, 75, 3, true, 0, false, true, 11, 'M');
			$pdf->SetFont('helvetica', '', 15);
			$zip = substr($sales_order['zip'], 0, 3);
			$flag = '';
			foreach ($code as $k => $c)
			{
				foreach ($c as $v)
				{
					$tmp = explode('-', $v);
					if (empty($tmp[1]))
					{
						if ($tmp[0] == $zip)
						{
							$flag = $k;
							break;
						}
					}
					else
					{
						if ($zip >= $tmp[0] || $zip<= $tmp[1])
						{
							$flag = $k;
							break;
						}
					}
				}
			}
			$pdf->MultiCell(23, '', $flag, 0, 'L', 0, 1, 83, 13, true, 0, false, true, 11, 'M');
			$pdf->Ln(3);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(60, '', 'wenfeng he<br>2 FLOOR,AIR MAIL PROCESSING CENTER<br> #3 YUNXIAO ROAD<br>GUANGZHOUSHI,GUANGDONG<br>BAIYUNQU 510000<br><font size="5">Customs information avaliable on attached CN22.USPS Personnel Scan barcode below for delivery event information</font>', 1, 'L', 0, 0, '', '', true, 0, true, true);
			$zip = explode('-', $sales_order['zip']);
			$pdf->MultiCell(36.1, 23.5, 'zip ' . $zip[0], 1, 'C', 0, 1, '', '', true, 0, false, true, 23, 'B');
			$pdf->write1DBarcode($zip[0], 'C128', 62, 29, 32, 13, 0.45, array('align' => 'C', 'text' => false, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			$pdf->Ln(12);
			$pdf->SetFont('helvetica', '', 18);
			$pdf->MultiCell(20, 20, 'TO:', 1, 'C', 0, 0, '', '', true, 0, false, true, 20, 'M');
			$pdf->SetFont($font, '', 8);
			$pdf->MultiCell(76, 20, $address, 1, 'L', 0, 1, '', '', true, 0, false, true, 20, 'M');
			$pdf->SetFont('helvetica', '', 10);
			$pdf->MultiCell(96, 28, 'USPS DELIVERY CONFIRMATION ®', 1, 'C', 0, 0, '', '', true, 0, false, true, 20, 'T');
			$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', 2, 73, 96, 16, 0.45, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			
			//Page 2
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 5, 3, 30, 10, 'JPG', '', '', true, 300, '', false, false, 0, false, false, false);
			$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', 38, 8, 50, 12, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			$pdf->SetFont('helvetica', '', 6);
			$pdf->MultiCell(25, 3, "IMPORTANT:", 0, 'L', 0, 0, 0, 14, true);
			$pdf->SetFont('times', '', 6);
			$pdf->MultiCell(35, 20, "\nThe item/parcel may be \nopened officially.\nPlease print in English.", 0, 'L', 0, 0, 0, '', true);
			$pdf->SetFont('helvetica', '', 15);
			$pdf->MultiCell(9, 9, $flag, 1, 'C', 0, 0, 25, '', true, 0, false, true, 9, 'M');
			$pdf->SetFont('helvetica', '', 6);
			$pdf->MultiCell(35, 0, "FROM: wenfeng he", 0, 'L', 0, 1, 0, 25, true);
			$pdf->MultiCell(45, 0, "2 FLOOR,AIR MAIL PROCESSING \nCENTER #3 YUNXIAO ROAD BAIYUNQU\nGUANGZHOUSHI,GUANGDONG 510000\nPHONE: 18988932428", 0, 'L', 0, 1, 0, 30, true);
			$pdf->SetFont($font, '', 7);
			$pdf->MultiCell(55, 22, 'SHIP TO: ' . "\n" . $address, 1, 'L', 0, 0, 45, 26, true);
			$pdf->Ln(16.3);
			$pdf->SetFont('helvetica', '', 6);
			$pdf->MultiCell(45, 0, 'Fees(US $):', 1, 'L', 0, 1, 0, '', true);
			$pdf->MultiCell(45, 0, 'Certificate No.', 1, 'L', 0, 1, 0, '', true);
			$pdf->MultiCell(10, 0, 'No', 1, 'C', 0, 0, 0, '', true);
			$pdf->MultiCell(10, 0, 'Qty', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(41, 0, 'Description of Contents', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(10, 0, 'Kg.', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(13, 0, 'Val(US $)', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(16, 0, 'Goods Origin', 1, 'C', 0, 1, '', '', true);
			$pdf->MultiCell(10, 30, '1', 1, 'C', 0, 0, 0, '', true);
			$pdf->MultiCell(10, 30, $sales_order_item[0]['quantity'], 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(41, 30, 'Total Gross Weight (Kg.):', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(10, 30, $sales_order_item[0]['weight']/1000, 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(13, 30, $sales_order_item[0]['declared_value'], 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(16, 30, '', 1, 'C', 0, 1, '', '', true);
			
			$pdf->MultiCell(10, 0, '', 1, 'C', 0, 0, 0, '', true);
			$pdf->MultiCell(10, 0, $sales_order_item[0]['quantity'], 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(41, 0, 'Total Gross Weight (Kg.):', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(10, 0, $sales_order_item[0]['weight']/1000, 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(13, 0, $sales_order_item[0]['declared_value'], 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(16, 0, '', 1, 'C', 0, 1, '', '', true);
			$pdf->Ln(1);
			$pdf->SetFont('helvetica', '', 4.4);
			$pdf->MultiCell(100, '', "I certify then particulars given in this customs declaration are correct. This item does not contain any dangerous article, or articles prohitbited \nby legislation or by postal or customs regulations. I have met all aplicable exort filling requirements under foreign Trade Regulations.", 0, 'L', 0, 1, 0, '', true, 0, true, true);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(75, '', "Sender's Signature & Date Signed:", 0, 'L', 0, 0, 0, 92, true);
			$pdf->SetFont('helvetica', '', 14);
			$pdf->MultiCell(20, 0, 'CN22', 0, 'R', 0, 0, 80, 90, true);
						
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function BY_EU_Line_NL($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/BY/value'))
		{
			set_time_limit(0);
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$product = '';
			foreach ($sales_order_item as $soi)
			{
				$product .= $soi['product_number'] . ' * ' . $soi['quantity'];
			}
			$address = $sales_order['fullname'] . "\n";
			$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
			$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
			$address .= $sales_order['city'] . "\n";
			$address .= $sales_order['state'] . "\n";
			$address .= $sales_order['zip'] . "\n";
			$address .= $sales_order['country'] . "\n";
			$address .= ($sales_order['phone']) ? ($sales_order['phone'] . "\n") : '';
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'BY_EU_Line_NL.png', '', '', 94, 18, 'PNG', '', '', true, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, '', 25, true);
			$pdf->SetFont('helvetica', '', 10);
			$pdf->MultiCell(48, '', $sales_order['number'], 0, 'R', 0, 0, '', '', true);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->MultiCell(46, '', $sales_order['country'], 0, 'L', 0, 1, '', '', true);
			$pdf->setFont('helvetica', '', 10);
			$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 8, 0.45, array('cellfitalign' => 'C', 'text' => false), 'M');
			$pdf->Ln();
			$y = $pdf->GetY();
			$pdf->Line(4, $y + 1, 96, $y + 1, '');
			$pdf->setFont('helvetica', 'B', 10);
			$pdf->MultiCell(94, 8, $product, 0, 'R', 0, 1, '', '', true, true, 0, true, 8, 'M');
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function BY_EU_Line_RM($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/BY/value'))
		{
			set_time_limit(0);
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$product = '';
			foreach ($sales_order_item as $soi)
			{
				$product .= $soi['product_number'] . ' * ' . $soi['quantity'];
			}
			$address = $sales_order['fullname'] . "\n";
			$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
			$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
			$address .= $sales_order['city'] . "\n";
			$address .= $sales_order['state'] . "\n";
			$address .= $sales_order['zip'] . "\n";
			$address .= $sales_order['country'] . "\n";
			$address .= ($sales_order['phone']) ? ($sales_order['phone'] . "\n") : '';
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'BY_EU_Line_RM.png', '', '', 94, 18, 'PNG', '', '', true, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, '', 25, true);
			$pdf->SetFont('helvetica', '', 10);
			$pdf->MultiCell(48, '', $sales_order['number'], 0, 'R', 0, 0, '', '', true);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->MultiCell(46, '', $sales_order['country'], 0, 'L', 0, 1, '', '', true);
			$pdf->setFont('helvetica', '', 10);
			$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 8, 0.45, array('cellfitalign' => 'C', 'text' => false), 'M');
			$pdf->Ln();
			$y = $pdf->GetY();
			$pdf->Line(4, $y + 1, 96, $y + 1, '');
			$pdf->setFont('helvetica', 'B', 10);
			$pdf->MultiCell(94, 8, $product, 0, 'R', 0, 1, '', '', true, true, 0, true, 8, 'M');
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function BY_GB_Line($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/BY/value'))
		{
			set_time_limit(0);
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
				'sales_order_customer_info.*',
				'sales_order.*',
				'shop.gift_card'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$product = '';
			foreach ($sales_order_item as $soi)
			{
				$product .= $soi['product_number'] . ' * ' . $soi['quantity'];
			}
			$address = $sales_order['fullname'] . "\n";
			$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
			$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
			$address .= $sales_order['city'] . "\n";
			$address .= $sales_order['state'] . "\n";
			$address .= $sales_order['zip'] . "\n";
			$address .= $sales_order['country'] . "\n";
			$address .= ($sales_order['phone']) ? ($sales_order['phone'] . "\n") : '';
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CK1_IT_Line1.jpg', 30, 7, 16, 11, 'JPG', '', '', true, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(94, 18, '<table width="100%" border="1"><tr><td align="left">&nbsp;&nbsp;Royal Mail<br><font size="10"><B> 48</B></font></td><td><B>Delivered by</B></td><td bgcolor="black"><font size="35" color="white"><B>48</B></font></td><td align="left"><font size="9" style="line-height: 5px;"><B> ROYAL MAIL</B></font><br><br><br><font size="6"> POSTAGE PAID GB<br> HQ38804</font></td></tr></table>', 0, 'C', 0, 1, '', '', true, 0, true, true);
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, '', '', true);
			$pdf->SetFont('helvetica', '', 10);
			$pdf->MultiCell(48, '', $sales_order['number'], 0, 'R', 0, 0, '', '', true);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->MultiCell(46, '', $sales_order['country'], 0, 'L', 0, 1, '', '', true);
			$pdf->setFont('helvetica', '', 10);
			$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 8, 0.45, array('cellfitalign' => 'C', 'text' => false), 'M');
			$pdf->Ln();
			$y = $pdf->GetY();
			$pdf->Line(4, $y + 1, 96, $y + 1, '');
			$pdf->setFont('helvetica', '', 10);
			$pdf->MultiCell(94, 8, $product, 0, 'R', 0, 1, '', '', true, true, 0, true, 8, 'M');
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function BY_R_GB_Line($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/BY/value'))
		{
			set_time_limit(0);
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
				'sales_order_customer_info.*',
				'sales_order.*',
				'shop.gift_card'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$product = '';
			foreach ($sales_order_item as $soi)
			{
				$product .= $soi['product_number'] . ' * ' . $soi['quantity'];
			}
			$address = $sales_order['fullname'] . "\n";
			$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
			$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
			$address .= $sales_order['city'] . "\n";
			$address .= $sales_order['state'] . "\n";
			$address .= $sales_order['zip'] . "\n";
			$address .= $sales_order['country'] . "\n";
			$address .= ($sales_order['phone']) ? ($sales_order['phone'] . "\n") : '';
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CK1_IT_Line1.jpg', 30, 7, 16, 11, 'JPG', '', '', true, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(94, 18, '<table width="100%" border="1"><tr><td align="left">&nbsp;&nbsp;Royal Mail<br><font size="10"><B> 48<br> Signed For</B></font></td><td><B>Delivered by</B></td><td bgcolor="black"><font size="35" color="white"><B>48</B></font></td><td align="left"><font size="9" style="line-height: 5px;"><B> ROYAL MAIL</B></font><br><br><br><font size="6"> POSTAGE PAID GB<br> HQ38804</font></td></tr></table>', 0, 'C', 0, 1, '', '', true, 0, true, true);
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, '', '', true);
			$y = $pdf->GetY();
			$pdf->MultiCell(94, '', 'T', 0, 'R', 0, 1, '', $y-3, true);
			$pdf->SetFont('helvetica', '', 10);
			$pdf->MultiCell(48, '', $sales_order['number'], 0, 'R', 0, 0, '', '', true);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->MultiCell(46, '', $sales_order['country'], 0, 'L', 0, 1, '', '', true);
			$pdf->setFont('helvetica', '', 10);
			$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 8, 0.45, array('cellfitalign' => 'C', 'text' => false), 'M');
			$pdf->Ln();
			$y = $pdf->GetY();
			$pdf->Line(4, $y + 1, 96, $y + 1, '');
			$pdf->setFont('helvetica', 'B', 10);
			$pdf->MultiCell(94, 8, $product, 0, 'R', 0, 1, '', '', true, true, 0, true, 8, 'M');
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function BY_EU_Line($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->setColumns($columns)->asArray()->getOne();
		$address = 'Send To: ' . $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . "\n";
		$address .= $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . "\n";
		$address .= $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ($sales_order['phone'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$return_address = 'H-10276' . "\n";
		$return_address .= 'If undeliverable, please return to:' . "\n";
		$return_address .= 'P.O.Box 7037' . "\n";
		$return_address .= '3109 AA Schiedam';
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(60, 25, $return_address, 1, 'C', 0, 0, '', '', true, true, 0, true, 30, 'M');
		$pdf->SetFont('times', 'B', 11);
		$pdf->MultiCell(60, 5, 'Prioritaire', 0, 'C', 0, 0, 4,3);
		$pdf->MultiCell(34, 25, 'Post NL' . "\n" . 'Port betaald' . "\n" . 'Port Payé' . "\n" . 'Pays-Bas', 1, 'L', 0, 1, '', '', true, true, 0, true, 25, 'M');
		$pdf->SetFont($font, '', 10);
		$pdf->Ln(2);
		$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', 'B', 11);
		$pdf->MultiCell(46, '', $sales_order['country'], 0, 'L', 0, 1, '', '', true);
		$y = $pdf->GetY();
		$pdf->Line(4, $y + 1, 96, $y + 1, '');
		$pdf->setFont('helvetica', '', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', $y + 3, 94, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->Ln();
		$pdf->MultiCell(94, '', '<table><tr><td align="left">NLFC</td><td align="right"><strong>H</strong></td></tr></table>', 0, 'C', 0, 1, '', '', true, 0, true, true);
		$pdf->Ln();
		$pdf->MultiCell(94, '', 'PCK', 0, 'L', 0, 1, '', '', true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function EUB($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order)
		{
			if (is_file(Q::ini('custom_system/eub_label_dir') . $sales_order['number'] . '.pdf'))
			{
				$label = file_get_contents(Q::ini('custom_system/eub_label_dir') . $sales_order['number'] . '.pdf');
				return array('ack' => SUCCESS, 'message' => '', 'label' => $label);
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
			}
		}
	}
	
	static function IEUB($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order)
		{
			if (is_file(Q::ini('custom_system/eub_label_dir') . $sales_order['number'] . '.pdf'))
			{
				$label = file_get_contents(Q::ini('custom_system/eub_label_dir') . $sales_order['number'] . '.pdf');
				return array('ack' => SUCCESS, 'message' => '', 'label' => $label);
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
			}
		}
	}
	
	static function _4PX_SGP_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = 'TO: ' . $sales_order['fullname'] . "\n";
		$address .= ($sales_order['phone']) ? ('Tel ' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ' ' . $sales_order['state'] . ' ' . $sales_order['zip'] . "\n";
		$address .= $sales_order['country'];
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$return = "CHANGI<br/>AIRFREIGHT CENTRE<br/><b>PO BOX 1191</b><br/>SINGAPORE<br/>918118";
		$pdf->SetFont('times', 'I', 9);
		$pdf->MultiCell(35, 23, $return , 0, 'L', 0, 0, '', '', true, 0, true, true, 23, 'M');
		$country = array(
			'A' => array('MY', 'BN', 'HK', 'ID', 'PH', 'TW', 'TH', 'SG', 'JP', 'US', 'NZ', 'AU', 'IT', 'AT', 'CH', 'DE', 'ES', 'FR', 'GB', 'SE'),
			'B' => array('AS', 'BD', 'BT', 'KH', 'CK', 'FJ', 'PF', 'GU', 'IN', 'KI', 'KP', 'KR', 'LA', 'MO', 'MV', 'MH', 'MN', 'MM', 'NR', 'NP', 'NU', 'MP', 'PK', 'PW', 'PG', 'WS', 'SB', 'LK', 'TO', 'VU', 'VN', 'CA', 'GR', 'NL'),
			'C' => array('AL', 'AM', 'AZ', 'BY', 'BE', 'BA', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'GE', 'GI', 'GL', 'HU', 'IS', 'IE', 'KZ', 'KG', 'LV', 'LI', 'LT', 'LU', 'MK', 'MT', 'MD', 'MC', 'NO', 'PL', 'PT', 'RO', 'SM', 'SK', 'SI', 'TJ', 'TR', 'TM', 'UZ', 'RS'),
			'D' => array('AD', 'AF', 'DZ', 'AO', 'AI', 'AG', 'AR', 'AW', 'BS', 'BH', 'BB', 'BZ', 'BJ', 'BM', 'BO', 'BW', 'BR', 'BI', 'CM', 'CV', 'KY', 'TD', 'CL', 'CO', 'KM', 'CG', 'CR', 'CU', 'CI', 'DJ', 'DM', 'DO', 'EC', 'EG', 'SV', 'GQ', 'ER', 'ET', 'GF', 'GA', 'GM', 'GH', 'GD', 'GP', 'GT', 'GN', 'GW', 'GY', 'HT', 'HN', 'IR', 'IQ', 'IL', 'JM', 'JO', 'KE', 'KW', 'LB', 'LS', 'LR', 'LY', 'MG', 'MW', 'ML', 'MQ', 'MR', 'MU', 'MX', 'MS', 'MA', 'MZ', 'NA', 'AN', 'NI', 'NE', 'NG', 'OM', 'PA', 'PY', 'PE', 'PR', 'QA', 'RE', 'RW', 'SA', 'SN', 'SC', 'SL', 'SO', 'ZA', 'KN', 'LC', 'VC', 'SD', 'SR', 'SZ', 'SY', 'TZ', 'TG', 'TT', 'TN', 'TC', 'UG', 'AE', 'UY', 'VE', 'YE', 'ZM', 'ZW', 'BV', 'CX', 'EH'),
			'E' => array('RU'),
			'F' => array('UA')
		);
		foreach ($country as $key => $c)
		{
			if (in_array($sales_order['country_code'], $c))
			{
				$pdf->SetFont('times', 'B', 10);
				$pdf->MultiCell(8, 23, $key, 0, 'C', 0, 1, '', '', true, 0, false, true, 23, 'M');
				break;
			}
		}
		$pdf->Image(Q::ini('custom_system/img_dir') . '4px_sgp_py.jpg', '', 3, 50, 24, 'JPG', '', '', true, 300, 'R', false, false, 0, false, false, false);
		$pdf->SetFont($font, '', 10);
		$pdf->MultiCell(69, 0, $address, 0, 'L', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 8);
		$pdf->MultiCell(25, 0, 'AIR MAIL<br><font face="cid0cs">航</font>PAR AVION<font face="cid0cs">空</font>', 1, 'C', 0, 1, 71.5, 28, true, 0, true, true);
		$pdf->MultiCell(25, 0, "zone", 1, 'C', 0, 1, 71.5, '', true);
		$pdf->SetFont('times' , 'B', 18);
		$pdf->MultiCell(25, 0, $sales_order['country_code'], 1, 'C', 0, 1, 71.5, '', true);
		$pdf->SetFont('times' , '', 12);
		$pdf->MultiCell(94, 25, "4PX WORLDWIDE EXPRESS", 1, 'C', 0, 1, '', 60, true);
		$pdf->Ln(0.8);
		$y = $pdf->GetY();
		$pdf->MultiCell(94, '', $sales_order['tracking_number'], 0, 'C', 0, 1, '', ($y - 20), true);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', ($y - 14), 94, 13, 0.5, array('text' => false, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('helvetica' , '', 10);
		$flag = $sales_order['shipping_method'] == 4 ? 'SGPY' : '4PSGOM+';
		$pdf->MultiCell(94, '', $flag."       [202126338]         Ref No: " . $sales_order['number'], 1, 'L', 0, 1, '', $y, true);
		$pdf->Ln(0.8);
		$pdf->MultiCell(94, '', "CS:S2692   SD:S0212 (X101)", 1, 'L', 0, 1, '', '', true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 8, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 9, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 10, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(94, 22, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(94, 6, $sales_order['number'], 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function _4PX_R_SGP_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/4PX/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card',
					'country.code as country_code'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
					->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$address = 'TO: ' . $sales_order['fullname'] . "\n";
				$address .= ($sales_order['phone']) ? ('Tel ' . $sales_order['phone'] . "\n") : '';
				$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
				$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
				$address .= $sales_order['city'] . ' ' . $sales_order['state'] . ' ' . $sales_order['zip'] . "\n";
				$address .= $sales_order['country'] . "\n\n";
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$return = "CHANGI<br/>AIRFREIGHT CENTRE<br/><b>PO BOX 1191</b><br/>SINGAPORE<br/>918118";
				$pdf->SetFont('times', 'I', 9);
				$pdf->MultiCell(35, 23, $return , 0, 'L', 0, 0, '', '', true, 0, true, true, 23, 'M');
				$country = array(
					'A' => array('MY', 'BN', 'HK', 'ID', 'PH', 'TW', 'TH', 'SG', 'JP', 'US', 'NZ', 'AU', 'IT', 'AT', 'CH', 'DE', 'ES', 'FR', 'GB', 'SE'),
					'B' => array('AS', 'BD', 'BT', 'KH', 'CK', 'FJ', 'PF', 'GU', 'IN', 'KI', 'KP', 'KR', 'LA', 'MO', 'MV', 'MH', 'MN', 'MM', 'NR', 'NP', 'NU', 'MP', 'PK', 'PW', 'PG', 'WS', 'SB', 'LK', 'TO', 'VU', 'VN', 'CA', 'GR', 'NL'),
					'C' => array('AL', 'AM', 'AZ', 'BY', 'BE', 'BA', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'GE', 'GI', 'GL', 'HU', 'IS', 'IE', 'KZ', 'KG', 'LV', 'LI', 'LT', 'LU', 'MK', 'MT', 'MD', 'MC', 'NO', 'PL', 'PT', 'RO', 'SM', 'SK', 'SI', 'TJ', 'TR', 'TM', 'UZ', 'RS'),
					'D' => array('AD', 'AF', 'DZ', 'AO', 'AI', 'AG', 'AR', 'AW', 'BS', 'BH', 'BB', 'BZ', 'BJ', 'BM', 'BO', 'BW', 'BR', 'BI', 'CM', 'CV', 'KY', 'TD', 'CL', 'CO', 'KM', 'CG', 'CR', 'CU', 'CI', 'DJ', 'DM', 'DO', 'EC', 'EG', 'SV', 'GQ', 'ER', 'ET', 'GF', 'GA', 'GM', 'GH', 'GD', 'GP', 'GT', 'GN', 'GW', 'GY', 'HT', 'HN', 'IR', 'IQ', 'IL', 'JM', 'JO', 'KE', 'KW', 'LB', 'LS', 'LR', 'LY', 'MG', 'MW', 'ML', 'MQ', 'MR', 'MU', 'MX', 'MS', 'MA', 'MZ', 'NA', 'AN', 'NI', 'NE', 'NG', 'OM', 'PA', 'PY', 'PE', 'PR', 'QA', 'RE', 'RW', 'SA', 'SN', 'SC', 'SL', 'SO', 'ZA', 'KN', 'LC', 'VC', 'SD', 'SR', 'SZ', 'SY', 'TZ', 'TG', 'TT', 'TN', 'TC', 'UG', 'AE', 'UY', 'VE', 'YE', 'ZM', 'ZW', 'BV', 'CX', 'EH'),
					'E' => array('RU'),
					'F' => array('UA')
				);
				foreach ($country as $key => $c)
				{
					if (in_array($sales_order['country_code'], $c))
					{
						$pdf->SetFont('times', 'B', 10);
						$pdf->MultiCell(8, 23, $key, 0, 'C', 0, 1, '', '', true, 0, false, true, 23, 'M');
						break;
					}
				}
				$pdf->Image(Q::ini('custom_system/img_dir') . '4px_r_sgp_package.jpg', '', 3, 50, 24, 'JPG', '', '', true, 300, 'R', false, false, 0, false, false, false);
				$pdf->SetFont('helvetica', '', 8);
				$pdf->MultiCell(25, 0, 'AIR MAIL<br><font face="cid0cs">航</font>PAR AVION<font face="cid0cs">空</font>', 1, 'C', 0, 0, 72, 28, true, 0, true, true);
				$pdf->SetFont($font, '', 10);
				$pdf->MultiCell(80, 0, $address, 0, 'L', 0, 1, 3, '', true);
				$pdf->SetFont('times' , 'B', 18);
				$pdf->MultiCell(94, 20, ' R', 1, 'L', 0, 1, '', '', true);
				$y = $pdf->GetY();
				$pdf->SetFont('times' , '', 13);
				$pdf->MultiCell(94, '', $sales_order['tracking_number'], 0, 'C', 0, 1, '', ($y - 18), true);
				$pdf->Line(5, ($y - 12), 95, ($y - 12));
				$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', '', ($y - 11), 94, 11, 0.45, array('text' => false, 'cellfitalign' => 'C'), 'M');
				$pdf->SetFont('helvetica' , '', 10);
				$pdf->MultiCell(94, '', 'SGGH' . ($sales_order['country_code'] == 'JP' ? '' : 'TH') . '       [202126338]        Ref No: ' . $sales_order['number'], 1, 'L', 0, 1, '', $y, true);
				$pdf->MultiCell(94, '', 'CS:S4245     SD:S0212 (X101)', 1, 'L', 0, 1, '', '', true);
				$pdf->AddPage();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->SetFont('times', 'B', 10);
				$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
				$pdf->SetFont('times', '', 8);
				$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
				$pdf->SetFont('times', 'B', 15);
				$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
				$pdf->SetFont('times', '', 9);
				$pdf->MultiCell(94, 8, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 9, 'M');
				$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
				$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
				$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
				$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
				$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
				$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
				$pdf->SetFont('times', 'B', 9);
				$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
				$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
				$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
				$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
				$pdf->SetFont('times', '', 8);
				$pdf->MultiCell(94, 8, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(94, 16, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 16, 'M');
				$pdf->SetFont('helvetica', '', 10);
				$pdf->MultiCell(94, 6, $sales_order['number'], 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function Standard($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont($font, '', 10);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', '', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('helvetica', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function Other($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont($font, '', 12);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', 'B', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('helvetica', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function SFC_DE_Rapid_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/SFC/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::Ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_en', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->setFont('helvetica', '', 10);
				$pdf->MultiCell(94, 20, "   Wenn unzustellbar,\n   zurück an:\n   Postfach 2007\n   36243 Niederaula", 1, 'L', 0, 0, '', '', true);
				$pdf->setFont('times', 'B', 11);
				$pdf->MultiCell(47, 6, "Deutsche Post", 1, 'C', 0, 1, 50, 3, true, 0, false, true, 6, 'M');
				$pdf->setFont('helvetica', '', 10);
				$pdf->MultiCell(47, 14, "Entgell bezahlt\n60544 Frankfurt\n(2378)", 1, 'C', 0, 1, 50, 9.1, true);
				$pdf->setFont('times', 'B', 12);
				$pdf->Ln(1);
				$pdf->MultiCell(94, 0, 'Von:A5305', 0, 'L', 0, 1, '', '', true);
				$address = 'Kunde: ' . $sales_order['fullname'] . "\n";
				$address .= 'Anschrift: ' . $sales_order['street1'] . "\n";
				$address .= $sales_order['zip'] . ' ' . $sales_order['city'] . ' ' . $sales_order['state'];
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf->setFont($font, '', 11);
				$pdf->MultiCell(94, 16, $address, 0, 'C', 0, 1, '', '', true);
				$pdf->Write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 94, 9, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'C');
				$pdf->Ln(4);
				$pdf->setFont('times', 'B', 15);
				$pdf->MultiCell(94, 0, 'DEAM1', 0, 'R', 0, 1, '', '', true);
				$pdf->setFont('helvetica', '', 8);
				$pdf->MultiCell(27, 8, 'Beschreibung', 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(8, 8, 'Zahl', 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(10, 8, "Preis\n(EUR)", 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(22, 8, "Ebay\nArtikelnummer", 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(27, 8, 'Rechnungsnummer', 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
				if (empty($sales_order_item[0]['shop_transaction_id']))
				{
					for ($i=0; $i<12; $i++)
					{
						$sales_order_item[0]['shop_transaction_id'] .= mt_rand(0, 9);
					}
				}
				$pdf->MultiCell(27, 5, $sales_order_item[0]['declared_name_en'], 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(8, 5, $sales_order_item[0]['quantity'], 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(10, 5, sprintf('%.2f', rand(5, 7)), 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(22, 5, $sales_order_item[0]['product_number'], 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(27, 5, $sales_order_item[0]['shop_transaction_id'], 1, 'L', 0, 1, '', '', true, 0, false, true, 5, 'M');
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function Bpost_EU_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/Bpost/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::Ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_en', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->setFont('helvetica', '', 7);
				$pdf->MultiCell(35, 10, date('Y-m-d'), 0, 'L', 0, 0, '', '', true, 0, false, true, 8, 'B');
				$pdf->Image(Q::ini('custom_system/img_dir') . 'bpost_eu_package.jpg', '', '', 30, 10, 'JPG', '', 'C', true, 300, 'B', false, false, 0, false, false, false);
				$pdf->MultiCell(30, 10, '', 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'C');
				$pdf->setFont('helvetica', 'B', 9);
				$pdf->MultiCell(28, 10, 'Belgique - Belgie', 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(35, 10, "Order NO:\nXS1300890465\n\nTO:", 0, 'L', 0, 0, '', '', true, 0, false, true, '', 'T');
				$pdf->setFont('helvetica', '', 5);
				$pdf->MultiCell(30, 10, "If undelivered please return to:\nPO BOX " . Q::ini('custom_api/Bpost_api_id') . "\n1934 EMC Brucargo-BELGIUM", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->setFont('helvetica', '', 7);
				$pdf->MultiCell(28, 5, 'P.P - P.B', 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(65, 5, '', 0, 'C', 0, 0, '', '', true, 0);
				$pdf->MultiCell(28, 5, Q::ini('custom_api/Bpost_api_id'), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$address = "\n\n" . $sales_order['fullname'] . "\n";
				$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
				$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
				$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
				$address .= $sales_order['zip'] . "\n" . $sales_order['country'] . "\n";
				$address .= ($sales_order['phone']) ? ('Tel:' . $sales_order['phone'] . "\n") : '';
				$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf->setFont($font, '', 9);
				$pdf->MultiCell('', '', $address, 0, 'L', 0, 1, '', '');
				$pdf->Ln(5);
				$pdf->Write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 95, 12, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'C');
				$pdf->Ln(6);
				$product = '';
				foreach ($sales_order_item as $key => $soi)
				{
					$product .= $soi['product_number'];
					if (count($sales_order_item) != ($key+1))
					{
						$product .= ', ';
					}
				}
				$pdf->MultiCell('', '', 'SKU: ' . $product, 0, 'L', 0, 1, '', '', true);
				$pdf->MultiCell(90, '', 'Email: ' . $sales_order['email'], 0, 'L', 0, 0, '', '', true);
				$pdf->setFont('helvetica', 'B', 30);
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
		}
	}
	
	static function CK1_US_Line($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/CK1/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->setFont('helvetica', '', 10);
				$pdf->Write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 95, 10, 0.4, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'C');
				$pdf->Ln(6);
				$pdf->setFont('times', 'B', 15);
				$pdf->MultiCell('', '', '         EAST', 0, 'L', 0, 1, '', '', true);
				$pdf->Line(96, $pdf->GetY(), 4, $pdf->GetY());
				$pdf->setFont('helvetica', '', 15);
				$pdf->MultiCell('', '', '        ' . sprintf("%.1f", $sales_order['weight']/28.5) . '  Oz                         CUE', 0, 'L', 0, 1, '', '', true);
				$pdf->Line(96, $pdf->GetY(), 4, $pdf->GetY());
				$pdf->Ln(30);
				$pdf->Line(96, $pdf->GetY()-2, 4, $pdf->GetY()-2);
				$pdf->MultiCell('', '', '        ' . $sales_order['number'] . ' * ' . $sales_order['product_quantity'], 0, 'L', 0, 1, '', '', true);
				$pdf->Line(96, $pdf->GetY()+2, 4, $pdf->GetY()+2);
				$pdf->Ln(5);
				$pdf->setFont('helvetica', '', 10);
				$pdf->Write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 95, 10, 0.4, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'C');
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
		}
	}
	
	static function SE_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_name_en, declared_value', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip']  . "\n";
		$address .= $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->Image(Q::ini('custom_system/img_dir') . 'sweden_gh.jpg', 4, 4, 92, 33, '', '', 'L', false, 300, '', false, false, 0, false, false, false);
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(94, '', 'Deliver To:', 0, 'L', 0, 1, '', 40, true);
		$pdf->SetFont($font, '', 11);
		$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, '', 47, true);
		$pdf->Ln(2);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->setFont('times', '', 10);
		$pdf->MultiCell(94, 12, "CUSTOM DECLARATION\nPostal Administration(may be opened officially)           important", 1, 'L', 0, 1, '', '', true, 0, false, true, 12, 'M');
		$pdf->setFont('times', 'B', 13);
		$pdf->MultiCell('', 12, 'CN22', 0, 'R', 0, 1, 80, 3, true);
		$pdf->setFont('times', '', 10.5);
		$pdf->MultiCell(5, 5, '', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(35, 5, 'Gift', 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(5, 5, '', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(49, 5, 'Sample', 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(5, 5, '', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(35, 5, 'Printed matter', 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(5, 5, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(49, 5, 'Others(tick as appropriate)', 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(60, 10, "Detailed description of contents:\n            {$sales_order_item[0]['declared_name_en']}", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(34, 10, "Value\nus\$" . sprintf('%.2f', $sales_order_item[0]['declared_value'] >= 21 ? 21 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(30, 10, "Origin:\n            CN", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(30, 10, "Total weight(kg)\n" . sprintf('%.3f', $sales_order['estimated_weight'] / 1000), 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(34, 10, "Total value\nus\$" . sprintf('%.2f', $sales_order_item[0]['declared_value'] >= 21 ? 21 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->setFont('times', '', 9);
		$pdf->MultiCell(94, 18, "I the undersigned whose name and address are given on the item,certi fy that particulars given in this declaration are correct and this item does not contain any dangerous articles prohibited by legislation or by postal or customs regulations", 1, 'L', 0, 1, '', '', true, 0, false, true, 18, 'M');
		$pdf->setFont('times', '', 10);
		$pdf->MultiCell(94, 12, "DATE AND SENDER'S SIGNATURE:", 1, 'L', 0, 1, '', '', true);
		$pdf->setFont('times', 'B', 12);
		$pdf->MultiCell(94, '', "{$sales_order['number']}", 0, 'C', 0, 1, '', $pdf->GetY()-7, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}

	static function FT_Global_Package_TH($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->MultiCell(25, 0, '<font face="cid0cs">客户</font>ID: 13170', 0, 'C', 0, 1, '', '', true, 0, 1);
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
		$address .= ($sales_order['phone']) ? ('Telephone:' . $sales_order['phone'] . "\n") : '';
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf->SetFont($font, '', 12);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', 'B', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('helvetica', '', 11);
		$pdf->MultiCell(37, 13, '<div style="line-height: 5px;">BY AIR MAIL</div><font face="cid0cs">航</font> PAR AVION <font face="cid0cs">空</font>', 1, 'C', 0, 0, '', '', $reseth=true, $strech=0, 1, $autopadding=true, $maxh=13, $valign='M');
		$pdf->MultiCell(10, 13, "1", 1, 'C', 0, 0, '', '', $reseth=true, $strech=0, $ishtml=false, $autopadding=true, $maxh=13, $valign='M');
		$pdf->SetFont('helvetica', '', 8);
		$pdf->MultiCell(27, 13, "POSTAGE PAID\nHONG KONG\nPORT PATY", 1, 'C', 0, 0, '', '', $reseth=true, $strech=0, $ishtml=false, $autopadding=true, $maxh=13, $valign='M');
		$pdf->MultiCell(20, 13, "PERMIT\nNO\n4532", 1, 'C', 0, 1, '', '', $reseth=true, $strech=0, $ishtml=false, $autopadding=true, $maxh=13, $valign='M');
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 9);
		$pdf->MultiCell(94, 0, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, 1);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(20, 8, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, "Value", 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', 'B', 9);
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, 1);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 8);
		$pdf->MultiCell(94, 0, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(94, 0, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(94, 0, $sales_order['number'], 1, 'C', 0, 1, '', '', true, 0, false, true, 0, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function CN_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.name as shop_name',
			'country.code as country_code, country.cn_name as country_cn',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_name_cn, declared_name_en, declared_value', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$declared_value = 0;
		foreach ($sales_order_item as $i)
		{
			$declared_value += $i['declared_value'];
		}
		$declared_value = ($declared_value > 20) ? 19.9 : $declared_value;
		$address = 'TO: ' . $sales_order['fullname'] . "\n       " . $sales_order['street1'] . ' ' . $sales_order['street2'] . "\n       " . $sales_order['state'] . ', ' . $sales_order['city'] . "\n       " . $sales_order['country'] . "\n" . 'Zip: ' . $sales_order['zip'] . '                    Tel: ' . $sales_order['phone'];
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 4, 28, 12, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
		$pdf->SetFont('helvetica', '', 12);
		$pdf->MultiCell(94, 16, '<font face="cid0cs">航空</font><br>Small packet<br>BY AIR', 1, 'C', 0, 1, '', '', true, 0, true, true);
		$pdf->SetFont('helvetica', '', 9);
		$pdf->MultiCell('', 11, $sales_order['country_code'] . '<font face="cid0cs"> ' . $sales_order['country_cn'] . '</font>', 0, 'R', 0, 1, '', 8, true, 0, true, true);
		$pdf->SetFont('cid0cs', '', 10);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 8, '协议客户：苏州8号仓（32050315065400）', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
		$pdf->MultiCell(94, 8, 'FROM：苏州市工业园区钟慧路102', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
		$pdf->SetFont($font, '', 10);
		$pdf->MultiCell(94, '', $address, 1, 'L', 0, 1, '', '', true, 0, false, true);
		$y1 = $pdf->GetY();
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(94, 8, '退件单位：君轩贸易（苏州市大宗处理中心）', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
		$y2 = $pdf->GetY();
		$pdf->MultiCell(94, 15, '', 1, 'L', 0, 1, '', '', true, 0, false, true, 15, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', 20, $y2+2, 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->Ln(9);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, '<font face="cid0cs">'. $sales_order['shipping_method_name'] . '</font>', 1, 'R', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->MultiCell(60, '', '<font face="cid0cs">报关签条<\font><br><font face="helvetica">CUSTOMS DECLARATION</font>', 0, 'L', 0, 0, '', '', true, 0, true);
		$pdf->SetFont('cid0cs', '', 8);
		$pdf->MultiCell(34, '', '邮 2113', 0, 'R', 0, 1, '', '', true, 0, false, true, 9, 'B');
		$pdf->MultiCell(60, '', '可以径行开拆<br><font face="helvetica">May be opened officially</font>', 0, 'L', 0, 0, '', '', true, 0, true);
		$pdf->SetFont('helvetica', 'B', 12);
		$pdf->MultiCell(34, 8, 'CN22', 0, 'R', 0, 1, '', '', true);
		$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 20.5, 25, 8, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(94, 9, '<font face="cid0cs" size="9">请先阅读背面的注意事项</font><br><font size="9">See instructions on the back</font>', 1, 'R', 0, 1, '', '', true, 0, true);
		$pdf->MultiCell(40, 14, '<font face="cid0cs" style="line-height: 8px;">邮件种类(在适当的文字前划"√")</font><br>Calegory of item. Tick as appropriate', 1, 'L', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(19, 7, '<font face="cid0cs">礼品</font><br>Gift', 1, 'C', 0, 0, '', '', true, 0, true);
		$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(25, 7, '<font face="cid0cs">商品货样</font><br>Commercial sample', 1, 'C', 0, 1, '', '', true, 0, true);
		$pdf->MultiCell(40, 7, '', 0, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(19, 7, '<font face="cid0cs">文件</font><br>Documents', 1, 'C', 0, 0, '', '', true, 0, true);
		$pdf->MultiCell(5, 7, '<font face="cid0cs" style="line-height: 7px;">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true, 7, 'M');
		$pdf->MultiCell(25, 7, '<font face="cid0cs">其他</font><br>Other', 1, 'C', 0, 1, '', '', true, 0, true);
		$pdf->MultiCell(45, 10, '<font face="cid0cs">内件详细名称和数量</font><br>Quantity and detailed detailed description of contents', 1, 'L', 0, 0, '', '', true, 0, true, true, 10, 'M');
		$pdf->MultiCell(24, 10, '<font face="cid0cs" style="line-height: 7px;">重量(千克)</font><br>Weight(kg)', 1, 'C', 0, 0, '', '', true, 0, true, true, 10, 'M');
		$pdf->MultiCell(25, 10, '<font face="cid0cs" style="line-height: 7px;">价值</font><br>Value', 1, 'C', 0, 1, '', '', true, 0, true, true, 10, 'M');
		$pdf->MultiCell(45, 5, $sales_order_item[0]['declared_name_en'] . ' <font face="cid0cs" style="line-height: 5px;">' . $sales_order_item[0]['declared_name_cn'] . '</font>', 1, 'C', 0, 0, '', '', true, 0, true);
		$weight = ($sales_order['weight']/1000 <= 2) ? $sales_order['weight']/1000 : 1.99;
		$pdf->MultiCell(24, 5, sprintf('%.2f', $weight / $sales_order['product_quantity']), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
		$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value / $sales_order['product_quantity']), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
		$pdf->MultiCell(45, 13, '<font face="cid0cs">协调系统税则号列和货物原产国<br>(只对商品邮件填写)</font><br>HS tariff number and country of origin of goods(Frocommercial items only)', 1, 'L', 0, 0, '', '', true, 0, true);
		$pdf->MultiCell(24, 13, '<font face="cid0cs" style="line-height: 10px;">总重量</font><br>Total Weight', 1, 'C', 0, 0, '', '', true, 0, true, true, 13, 'M');
		$pdf->MultiCell(25, 13, '<font face="cid0cs" style="line-height: 10px;">总价值</font><br>Total Value', 1, 'C', 0, 1, '', '', true, 0, true, true, 13, 'M');
		$pdf->MultiCell(45, 5, 'China', 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
		$pdf->MultiCell(24, 5, sprintf('%.2f', $weight), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
		$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
		$pdf->Ln(1);
		$pdf->MultiCell(94, 0, '<font face="cid0cs">我保证上述申报准确无误，本函件内未装寄法律或邮政和海关规章禁止寄递的任何危险物品</font><br>I,the undersigned,certify that the particulars given in this declaraton are correct and this item does not contain any dangerous articles prohibited by lagislation or by postal or custome regulations', 0, 'L', 0, 1, '', '', true, 0, true);
		$pdf->Ln(1);
		$pdf->SetFont('helvetica', '', 9);
		$pdf->MultiCell(94, 0, '<table><tr><td width="90%"><font face="cid0cs">寄件人签字 </font>Sender\'s signature(9):</td><td>HJW</td></tr></table>', 0, 'L', 0, 1, '', '', true, 0, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function R_CN_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.name as shop_name',
			'country.code as country_code, country.cn_name as country_cn',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		if ($sales_order['tracking_number'])
		{
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_name_en, declared_value', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
			$declared_value = 0;
			foreach ($sales_order_item as $i)
			{
				$declared_value += $i['declared_value'];
			}
			$declared_value = ($declared_value > 20) ? 19.9 : $declared_value;
			$address = 'TO: ' . $sales_order['fullname'] . "\n       " . $sales_order['street1'] . ' ' . $sales_order['street2'] . "\n       " . $sales_order['state'] . ', ' . $sales_order['city'] . "\n       " . $sales_order['country'] . "\n" . 'Zip: ' . $sales_order['zip'] . '                    Tel: ' . $sales_order['phone'];
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 4, 28, 12, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 12);
			$pdf->MultiCell(94, 16, '<font face="cid0cs">航空</font><br>Small packet<br>BY AIR', 1, 'C', 0, 1, '', '', true, 0, true, true);
			$pdf->MultiCell('', 11, $sales_order['country_code'] . '<font face="cid0cs"> ' . $sales_order['country_cn'] . '</font>', 0, 'R', 0, 1, '', 8, true, 0, true, true);
			$pdf->SetFont('cid0cs', '', 10);
			$country_code_y = $pdf->GetY();
			$pdf->MultiCell(94, 8, '协议客户： 00640277680466', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$pdf->MultiCell(94, 12, 'FROM： 中国广州市体育东路32号苏红飞 D1' . "\n" . 'Zip： 510620                       Tel ： 13632426510', 1, 'L', 0, 1, '', '', true, 0, false, true, 12, 'M');
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 1, 'L', 0, 1, '', '', true, 0, false, true);
			$y1 = $pdf->GetY();
			$pdf->SetFont('cid0cs', '', 10);
			$pdf->MultiCell(94, 8, '退件单位： 国际函件运营中心PETIT PAQET', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$pdf->MultiCell('', '', '<font size="5"><div>PAR AVI ON：已验视</div>验视人：曾娥珍</font>', 0, 'L', 0, 1, 75, $y1-1, true, 0, true, true);
			$y2 = $pdf->GetY();
			$pdf->MultiCell(94, 15, '', 1, 'L', 0, 1, '', '', true, 0, false, true, 15, 'M');
			$pdf->SetFont('helvetica', '', 10);
			$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', 20, $y2+2, 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			$pdf->Ln(9);
			$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
			$pdf->MultiCell(27, 0, '<font face="cid0cs">'. $sales_order['shipping_method_name'] . '</font>', 1, 'R', 0, 0, '', '', true, 0, true, true);
			$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
			$pdf->AddPage();
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->MultiCell(60, '', '<font face="cid0cs">报关签条<\font><br><font face="helvetica">CUSTOMS DECLARATION</font>', 0, 'L', 0, 0, '', '', true, 0, true);
			$pdf->SetFont('cid0cs', '', 8);
			$pdf->MultiCell(34, '', '邮 2113', 0, 'R', 0, 1, '', '', true, 0, false, true, 9, 'B');
			$pdf->MultiCell(60, '', '可以径行开拆<br><font face="helvetica">May be opened officially</font>', 0, 'L', 0, 0, '', '', true, 0, true);
			$pdf->SetFont('helvetica', 'B', 12);
			$pdf->MultiCell(34, 8, 'CN22', 0, 'R', 0, 1, '', '', true);
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 20.5, 25, 8, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(94, 9, '<font face="cid0cs" size="9">请先阅读背面的注意事项</font><br><font size="9">See instructions on the back</font>', 1, 'R', 0, 1, '', '', true, 0, true);
			$pdf->MultiCell(40, 14, '<font face="cid0cs" style="line-height: 8px;">邮件种类(在适当的文字前划"√")</font><br>Calegory of item. Tick as appropriate', 1, 'L', 0, 0, '', '', true, 0, true, true);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(19, 7, '<font face="cid0cs">礼品</font><br>Gift', 1, 'C', 0, 0, '', '', true, 0, true);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(25, 7, '<font face="cid0cs">商品货样</font><br>Commercial sample', 1, 'C', 0, 1, '', '', true, 0, true);
			$pdf->MultiCell(40, 7, '', 0, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(19, 7, '<font face="cid0cs">文件</font><br>Documents', 1, 'C', 0, 0, '', '', true, 0, true);
			$pdf->MultiCell(5, 7, '<font face="cid0cs" style="line-height: 7px;">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true, 7, 'M');
			$pdf->MultiCell(25, 7, '<font face="cid0cs">其他</font><br>Other', 1, 'C', 0, 1, '', '', true, 0, true);
			$pdf->MultiCell(45, 10, '<font face="cid0cs">内件详细名称和数量</font><br>Quantity and detailed detailed description of contents', 1, 'L', 0, 0, '', '', true, 0, true, true, 10, 'M');
			$pdf->MultiCell(24, 10, '<font face="cid0cs" style="line-height: 7px;">重量(千克)</font><br>Weight(kg)', 1, 'C', 0, 0, '', '', true, 0, true, true, 10, 'M');
			$pdf->MultiCell(25, 10, '<font face="cid0cs" style="line-height: 7px;">价值</font><br>Value', 1, 'C', 0, 1, '', '', true, 0, true, true, 10, 'M');
			$pdf->MultiCell(45, 5, $sales_order_item[0]['declared_name_en'] . ' ' . $sales_order_item[0]['product_number'], 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$weight = ($sales_order['weight']/1000 <= 2) ? $sales_order['weight']/1000 : 1.99;
			$pdf->MultiCell(24, 5, sprintf('%.2f', $weight / $sales_order['product_quantity']), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value / $sales_order['product_quantity']), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(45, 13, '<font face="cid0cs">协调系统税则号列和货物原产国<br>(只对商品邮件填写)</font><br>HS tariff number and country of origin of goods(Frocommercial items only)', 1, 'L', 0, 0, '', '', true, 0, true);
			$pdf->MultiCell(24, 13, '<font face="cid0cs" style="line-height: 10px;">总重量</font><br>Total Weight', 1, 'C', 0, 0, '', '', true, 0, true, true, 13, 'M');
			$pdf->MultiCell(25, 13, '<font face="cid0cs" style="line-height: 10px;">总价值</font><br>Total Value', 1, 'C', 0, 1, '', '', true, 0, true, true, 13, 'M');
			$pdf->MultiCell(45, 5, 'China', 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(24, 5, sprintf('%.2f', $weight), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
			$pdf->Ln(1);
			$pdf->MultiCell(94, 0, '<font face="cid0cs">我保证上述申报准确无误，本函件内未装寄法律或邮政和海关规章禁止寄递的任何危险物品</font><br>I,the undersigned,certify that the particulars given in this declaraton are correct and this item does not contain any dangerous articles prohibited by lagislation or by postal or custome regulations', 0, 'L', 0, 1, '', '', true, 0, true);
			$pdf->Ln(1);
			$pdf->SetFont('helvetica', '', 9);
			$pdf->MultiCell(94, 0, '<table><tr><td width="73%"><font face="cid0cs">寄件人签字 </font>Sender\'s signature</td><td>boxintheship.com</td></tr></table>', 0, 'L', 0, 1, '', '', true, 0, true);
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
		}
	}
	
	static function MY_Package($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = $sales_order['fullname'] . '<br>';
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . '<br>') : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . '<br>') : '';
		$address .= $sales_order['city'] . '<br>';
		$address .= $sales_order['state'] . '<br>';
		$address .= $sales_order['zip'] . '<br>';
		$address .= '<font face="cid0cs">' . $sales_order['country_cn'] . "</font>({$sales_order['country']})<br>";
		$address .= ($sales_order['phone']) ? ($sales_order['phone'] . '<br>') : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('helvetica', '', 16);
		$pdf->MultiCell(30, 22, 'AIR MAIL', 1, 'C', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 6);
		$pdf->MultiCell(63, 22, "If undelived, please return to:\n\nLocked Bag No. 0149\nSpecial Project Unit,\nPos Malaysia International Hub\nPos Malaysia Berhad\nJalan KLIA 1\n64009 Malaysia", 1, 'L', 0, 0, 34, 3, true, 0, false, true, 22, 'M');
		$pdf->MultiCell(25, 18, "BAYARAN POS JELAS\nPOSTAGE PAID\nPOS MALAYSIA\nINTERNATIONAL HUB,\nPMIH, MALAYSIA\nPMK 0149", 1, 'C', 0, 0, 70, 5, true, 0, false, true, 18, 'M');
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(94, '', "\nSEND TO:", 0, 'L', 0, 1, 3, 19, true);
		$pdf->SetFont($font, '', 10);
		$pdf->MultiCell(94, '', "\n\n\n\n" . $address, 0, 'L', 0, 1, 20, 35, true, 0, 1);
		$pdf->Ln(8);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 10, 0.45, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 9);
		$pdf->MultiCell(94, 0, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, 1);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, "Quantity(2) and detail\ndescription of contents(1)", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(20, 8, "(3)Weight\n(in kg)", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, "(5)Value", 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', 'B', 9);
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, 1);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, '(4)(6)Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 8);
		$pdf->MultiCell(94, 0, "For commercial items only. If known, HS tariff number(7) and country of origin of goods(8)", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(94, 0, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(94, 0, "(15)Date and sender's signature\n                                                                                                        GZH", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function MY_R_Package($sales_order_id)
	{
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('helvetica', '', 16);
		$pdf->MultiCell(30, 22, 'AIR MAIL', 1, 'C', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 6);
		$pdf->MultiCell(63, 22, "If undelived, please return to:\n\nLocked Bag No. 0149\nSpecial Project Unit,\nPos Malaysia International Hub\nPos Malaysia Berhad\nJalan KLIA 1\n64009 Malaysia", 1, 'L', 0, 0, 34, 3, true, 0, false, true, 22, 'M');
		$pdf->MultiCell(25, 18, "BAYARAN POS JELAS\nPOSTAGE PAID\nPOS MALAYSIA\nINTERNATIONAL HUB,\nPMIH, MALAYSIA\nPMK 0149", 1, 'C', 0, 0, 70, 5, true, 0, false, true, 18, 'M');
		$address = $sales_order['fullname'] . '<br>';
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . '<br>') : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . '<br>') : '';
		$address .= $sales_order['city'] . '<br>';
		$address .= $sales_order['state'] . '<br>';
		$address .= $sales_order['zip'] . '<br>';
		$address .= '<font face="cid0cs">' . $sales_order['country_cn'] . "</font>({$sales_order['country']})<br>";
		$address .= ($sales_order['phone']) ? ($sales_order['phone'] . '<br>') : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(94, '', "\nSEND TO:", 0, 'L', 0, 1, 3, 19, true);
		$pdf->SetFont($font, '', 10);
		$pdf->MultiCell(94, '', "\n\n\n\n" . $address, 0, 'L', 0, 1, 20, 35, true, 0, 1);
		$pdf->Ln(8);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 94, 10, 0.45, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('times', 'B', 20);
		$pdf->MultiCell('', '', 'R', 0, 'R', 0, 1, '', '', true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', '', 7);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 9);
		$pdf->MultiCell(94, 0, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, 1);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, "Quantity(2) and detail\ndescription of contents(1)", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(20, 8, "(3)Weight\n(in kg)", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, "(5)Value", 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', 'B', 9);
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, 1);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, '(4)(6)Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('helvetica', '', 8);
		$pdf->MultiCell(94, 0, "For commercial items only. If known, HS tariff number(7) and country of origin of goods(8)", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(94, 0, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(94, 0, "(15)Date and sender's signature\n                                                                                                        GZH", 1, 'L', 0, 1, '', '', true, 0, false, true, 0, 'M');
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function CK1_IT_Line($sales_order_id)
	{
		set_time_limit(0);
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/CK1/value'))
		{
			if ($sales_order['tracking_number'])
			{
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', '', 'product_basic.id=sales_order_item.product_basic_id')
					->setColumns('product_basic.number as product_number, sales_order_item.quantity')->asArray()->getAll();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->SetFont('times', 'B', 10);
				$pdf->MultiCell(30, 0, "BY AIRMAIL\nPAR AVION", 0, 'L', 0, 0, '', '', true);
				$pdf->SetFont('helvetica', 'B', 9);
				$pdf->MultiCell(22, 0, "Delivered by", 0, 'L', 0, 1, 30, 4, true);
				$pdf->Image(Q::ini('custom_system/img_dir') . 'CK1_IT_Line1.jpg', 32, 9, 16, 10, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
				$pdf->MultiCell(45, 14, '<table width="100%" border="1"><tr><td width="40px" bgcolor="black"><font align="right" size="35" color="white"><B>1</B></font></td><td width="80px" align="left"><font size="11" style="line-height: 5px;"><B> ROYAL MAIL</B></font><br><font size="7"> POSTAGE PAID GB<br> HQ39870</font></td></tr></table>', 0, 'L', 0, 1, 53, 3, true, 0, 1);
				$pdf->SetFont('times', '', 25);
				$pdf->MultiCell(50, 25, $sales_order['country'], 0, 'L', 0, 1, 5, 49, true);
				$pdf->Image(Q::ini('custom_system/img_dir') . 'CK1_IT_Line1.jpg', 70, 38, 25, 20, '', '', 'R', false, 300, '', false, false, 0, false, false, false);
				$address = $sales_order['fullname'] . "\n";
				$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
				$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
				$address .= $sales_order['city'] . ' ' . $sales_order['state'] . ' ' . $sales_order['zip'] . "\n";
				$address .= $sales_order['country']. "\n";
				$address .= ($sales_order['phone']) ? ("TEL: " . $sales_order['phone']) : '';
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf->SetFont($font, '', 11);
				$pdf->MultiCell(94, 40, $address, 1, 'L', 0, 1, '', 20, true);
				$pdf->MultiCell(94, 5, 'Custom:  ' . $sales_order['number'], 1, 'L', 0, 1, '', '', true);
				foreach ($sales_order_item as $key => $soi)
				{
					$ln = $key % 2;
					$product = $soi['product_number'] . ' * ' . $soi['quantity'];
					$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
				}
				if (count($sales_order_item) % 2 == 1)
				{
					$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
				}
				$pdf->SetFont('helvetica', '', 9);
				$pdf->MultiCell(94, '', "Return to:STONE BRIDGE,UNIT 10 EXPLORER VOYAGER\nPARK PORTFIELD ROAD,PORTSMOUTH,PO3 5FL,UK", 0, 'L', 0, 1, '', '', true);
				$pdf->Ln(1);
				$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 94, 9, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function DE_Line($sales_order_id)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
			'shop.gift_card',
			'country.code as country_code',
			'shipping_method.name as shipping_method_name'
		);
		$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
			->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
			->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
			->setColumns($columns)->asArray()->getOne();
		$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
			->joinLeft('product_basic', 'number as product_number, declared_name_en, declared_name_cn, weight', 'product_basic.id=sales_order_item.product_basic_id')
			->asArray()->getAll();
		$address = "Ship to:\n";
		$address .= $sales_order['fullname'] . "\n";
		$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
		$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
		$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
		$address .= $sales_order['country'] . "\n";
		$address .= 'Zip: ' . $sales_order['zip'] . '       ' . 'Tel: ' . $sales_order['phone'] . "\n";
		$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
		$font = Helper_BSS_Normal::getPdfAddFont($address);
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->AddPage();
		$pdf->SetFont('times', '', 10);
		$pdf->MultiCell(50, 20, "Wenn unzustellbar,<br/>zurück an:<br/><b>Postfach 1100<br/>36243 Niederaula</b>", 1, 'L', 0, 0, '', '', true, 0, true, true, 20, 'M');
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(44, 6, "Deutsche Post", 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
		$pdf->SetFont('times', '', 10);
		$pdf->MultiCell(44, 14, "<b>Entgelt bezahlt</b><br/>60544 Frankfurt<br/><b>39426</b>", 1, 'C', 0, 1, 53, '', true, 0, true, true, 14, 'M');
		$pdf->SetFont($font, '', 10);
		$country_code_y = $pdf->GetY();
		$pdf->MultiCell(94, 0, $address, 1, 'L', 0, 1, '', '', true);
		$pdf->SetFont('cid0cs', '', 10);
		$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
		$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
		foreach ($sales_order_item as $key => $soi)
		{
			$ln = $key % 2;
			$product = $soi['product_number'] . ' * ' . $soi['quantity'];
			$pdf->MultiCell(47, 0, $product, 1, 'L', 0, $ln, '', '', true);
		}
		if (count($sales_order_item) % 2 == 1)
		{
			$pdf->MultiCell(47, 0, '', 1, 'L', 0, 1, '', '', true);
		}
		$pdf->Ln(2);
		$pdf->SetFont('helvetica', 'B', 15);
		$pdf->MultiCell(18, 0, $sales_order['gift_card'], 0, 'C', 0, 0, '', '', true);
		$pdf->SetFont('helvetica', 'B', 10);
		$pdf->write1DBarcode($sales_order['number'], 'C128', '', '', 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
		$pdf->SetFont('times', 'B', 12);
		$pdf->MultiCell(94, '', $sales_order['country_code'], 0, 'R', 0, 1,'', $country_code_y, true);
		$pdf->AddPage();
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('times', 'B', 10);
		$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
		$pdf->SetFont('times', '', 8);
		$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
		$pdf->SetFont('times', 'B', 15);
		$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 8, "Postal administration", 0, 'L', 0, 1, '', '', true, 0, false, true, 9, 'M');
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
		$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
		$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
		$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
		$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
		$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
		$pdf->SetFont('times', '', 9);
		$pdf->MultiCell(94, 10, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 10, 'M');
		$pdf->MultiCell(94, 22, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.", 1, 'L', 0, 1, '', '', true, 0, false, true, 22, 'M');
		$pdf->SetFont('helvetica', '', 10);
		$pdf->MultiCell(94, 12, '<table><tr><td width="90%">Date and Sender\'s signature:</td><td><font size="15">Mak</font></td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true);
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function QT($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/QT/value'))
		{
			set_time_limit(0);
			$order = '<?xml version="1.0" encoding="utf-8"?>
			<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
			xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
			<soap:Body>
			<GetShippingLabel xmlns="http://diqisoft.com/">
			<orderId>'.$sales_order['lsp_number'].'</orderId>
			<code>KSW</code>
			<token>C6B52C3F05424C7BA146061EE5DC7E76</token>
			</GetShippingLabel>
			</soap:Body>
			</soap:Envelope>';
		
			$ch = curl_init('http://120.27.31.27:1680/api/shipping.asmx');
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
			curl_setopt($ch, CURLOPT_POSTFIELDS, $order);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_HTTPHEADER, array(
				'Content-Type: text/xml; charset=utf-8',
				'Content-Length: ' . strlen($order))
			);
			$result = curl_exec($ch);
			$p = xml_parser_create();
			xml_parse_into_struct($p, $result, $vals, $index);
			xml_parser_free($p);
			foreach ($vals as $v)
			{
				if ($v['tag'] == 'DATA' && !empty($v['value']))
				{
					header('Content-Type: application/pdf');
					header('Cache-Control: private, must-revalidate, post-check=0, max-age=1');
					header('Pragma: public');
					return array('ack' => SUCCESS, 'message' => '', 'label' => base64_decode($v['value']));
				}
			}
			return array('ack' => FAILURE, 'message' => '获取地址单失败', 'label' => '');
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function BUB($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/BUB/value'))
		{
			if ($sales_order['tracking_number'])
			{
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'country.code as country_code'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'weight, declared_value, declared_name_cn, declared_name_en', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$declared_value = 0;
				foreach ($sales_order_item as $i)
				{
					$declared_value += $i['declared_value'];
				}
				$declared_value = ($declared_value > 20) ? 19.9 : $declared_value;
				$acode = $sales_order['country_code'] . ' ' . $sales_order['country_cn'];
				if ($sales_order['country_code'] == 'RU')
				{
					if ($sales_order['zip'][0] > 5)
					{
						$acode = $sales_order['country_code'] . ' 俄罗斯（小）';
					}
					else
					{
						$acode = $sales_order['country_code'] . ' 俄罗斯（大）';
					}
				}
				$address = $sales_order['fullname'] . "\n" . $sales_order['street1'] . ' ' . $sales_order['street2'] . "\n" . $sales_order['city'] . ',' . $sales_order['state'] . ',' . $sales_order['country'];
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->Image(Q::ini('custom_system/img_dir') . 'BUB.jpg', 5, 6, 35, 8, 'jpg', '', '', true, 300, '', false, false, 0, false, false, false);
				$pdf->SetFont('helvetica', '', 8);
				$pdf->MultiCell(94, 16, '<font face="cid0cs" style="line-height: 7px;">航空</font><br>Small Packet<br>BY AIR', 1, 'C', 0, 1, '', '', true, 0, true, true);
				$pdf->SetFont('cid0cs', '', 8);
				$pdf->MultiCell(20, 5, '协议客户：', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(74, 5, '北京京 腾 一 诺 科技有限公司( 11010503959000)', 1, 'L', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->SetFont('helvetica', '', 8);
				$pdf->MultiCell(20, 18, 'From:', 1, 'L', 0, 0, '', '', true, 0, false, true, 11, 'M');
				$pdf->MultiCell(74, 18, 'xu shao peng<br><font face="cid0cs">广州市天河区骏景花园骏茵轩A3座404房</font>R404,junyinxuan,junjinghuayuan,GuangZhou, GuangDong, China', 1, 'L', 0, 1, '', '', true, 0, true, true);
				$pdf->MultiCell(20, 5, 'Zip:', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(27, 5, '', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(20, 5, 'Tel:', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(27, 5, '13580349452', 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(20, 18, 'To:', 1, 'L', 0, 0, '', '', true, 0, false, true, 18, 'M');
				$pdf->SetFont($font, '', '8');
				$pdf->MultiCell(74, 18, $address, 1, 'L', 0, 1, '', '', true, 0, false, true, 18, 'M');
				$pdf->MultiCell(20, 5, 'Zip:', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(27, 5, $sales_order['zip'], 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(20, 5, 'Tel:', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(27, 5,  $sales_order['phone'] ? $sales_order['phone'] : '', 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->SetFont('cid0cs', '', 8);
				$pdf->MultiCell(20, 5, '退件单位：', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(74, 5, '北京国际邮电局集中收寄网', 1, 'L', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$y = $pdf->GetY();
				$pdf->MultiCell(94, 15, '', 1, 'C', 0, 1, '', '', true);
				$pdf->SetFont('cid0cs', '', 8);
				$pdf->MultiCell(20, 5, '客户自编号：', 1, 'L', 0, 0, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(74, 5, $sales_order['number'], 1, 'L', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->SetFont('helvetica', '', 10);
				$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', 5, $y, 94, 8, 0.45, array('cellfitalign' => 'C', 'text' => true, 'stretchtext' => 5), 'M');
				$pdf->SetFont('cid0cs', 'B', 10);
				$pdf->MultiCell(92, '', $acode, 0, 'R', 0, 1, '', 8, true);
				$pdf->AddPage();
				$pdf->SetFont('helvetica', '', 7);
				$pdf->MultiCell(75, 0, '<font face="cid0cs">报关签条，可以径行开拆</font><br>CUSTOMS DECLARARTION, May be opened officially', 0, 'L', 0, 0, '', '', true, 0, 1);
				$pdf->MultiCell(19, 0, '<font face="cid0cs">邮 2113</font><br>CN22', 0, 'R', 0, 1, '', '', true, 0, 1);
				$pdf->Ln(1);
				$pdf->MultiCell(40, 14, '<font face="cid0cs" style="line-height:9px;">邮件种类（在适当的文字前划√）</font><br>Calegory of item. Tick as appropriate', 1, 'L', 0, 0, '', '', true, 0, 1, true, 14, 'M');
				$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(19, 7, '<font face="cid0cs">礼品</font><br>Gift', 1, 'C', 0, 0, '', '', true, 0, 1);
				$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(25, 7, '<font face="cid0cs">商品货样</font><br>Commercial sample', 1, 'C', 0, 1, '', '', true, 0, 1);
				$pdf->MultiCell(40, 7, '', 0, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(19, 7, '<font face="cid0cs">文件</font><br>Documents', 1, 'C', 0, 0, '', '', true, 0, 1);
				$pdf->MultiCell(5, 7, '<font face="cid0cs" style="line-height:7px;">√</font>', 1, 'C', 0, 0, '', '', true, 0, 1, true, 7, 'M');
				$pdf->MultiCell(25, 7, '<font face="cid0cs">其他</font><br>Other', 1, 'C', 0, 1, '', '', true, 0, 1);
				$pdf->SetFont('helvetica', '', 7);
				$pdf->MultiCell(45, 10, '<font face="cid0cs">内件详细名称和数量</font><br>Quantity and detailed detailed description of contents', 1, 'L', 0, 0, '', '', true, 0, 1, true, 10, 'M');
				$pdf->MultiCell(24, 10, '<font face="cid0cs" style="line-height:7px;">重量(千克)</font><br>Weight', 1, 'C', 0, 0, '', '', true, 0, 1, true, 10, 'M');
				$pdf->MultiCell(25, 10, '<font face="cid0cs" style="line-height:7px;">价值</font><br>Value', 1, 'C', 0, 1, '', '', true, 0, 1, true, 10, 'M');
				$pdf->MultiCell(45, 7, $sales_order_item[0]['declared_name_en'], 1, 'C', 0, 0, '', '', true, 0, false, true, 7, 'M');
				$weight = ($sales_order['weight']/1000 <= 2) ? $sales_order['weight']/1000 : 1.99;
				$pdf->MultiCell(24, 7, sprintf('%.2f', $weight / $sales_order['product_quantity']), 1, 'C', 0, 0, '', '', true, 0, false, true, 7, 'M');
				$pdf->MultiCell(25, 7, sprintf('%.2f', $declared_value / $sales_order['product_quantity']), 1, 'C', 0, 1, '', '', true, 0, false, true, 7, 'M');
				$pdf->MultiCell(45, 13, '<font face="cid0cs">协调系统税则号列和货物原产国<br>(只对商品邮件填写)</font><br>HS tariff number and country of origin of goods(Frocommercial items only)', 1, 'L', 0, 0, '', '', true, 0, 1);
				$pdf->MultiCell(24, 13, '<font face="cid0cs" style="line-height:10px;">总重量(千克)</font><br>Weight', 1, 'C', 0, 0, '', '', true, 0, 1, true, 13, 'M');
				$pdf->MultiCell(25, 13, '<font face="cid0cs" style="line-height:10px;">总价值</font><br>Value', 1, 'C', 0, 1, '', '', true, 0, 1, true, 13, 'M');
				$pdf->MultiCell(45, 7, 'China', 1, 'C', 0, 0, '', '', true, 0, false, true, 7, 'M');
				$pdf->MultiCell(24, 7, sprintf('%.2f', $weight), 1, 'C', 0, 0, '', '', true, 0, false, true, 7, 'M');
				$pdf->MultiCell(25, 7, sprintf('%.2f', $declared_value), 1, 'C', 0, 1, '', '', true, 0, false, true, 7, 'M');
				$pdf->Ln(1);
				$pdf->MultiCell(94, 0, '<font face="cid0cs">我保证上述申报准确无误，本函件内未装寄法律或邮政和海关规章禁止寄递的任何危险物品</font><br>I,the undersigned,certify that the particulars given in this declaraton are correct and this item does not contain any dangerous articles prohibited by lagislation or by postal or custome regulations', 0, 'L', 0, 1, '', '', true, 0, 1);
				$pdf->Ln(1);
				$pdf->SetFont('helvetica', '', 8);
				$pdf->MultiCell(94, 0, '<font face="cid0cs">寄件人签字</font> Sender\'s signature________________________________', 0, 'L', 0, 1, '', '', true, 0, 1);
				$pdf->ln(2);
				$pdf->MultiCell(45, 0, '<font face="cid0cs">标签生成日期</font><br>Label Creation Date ' . date('Y-m-d'), 1, 'C', 0, 0, '', '', true, 0, 1);
				$pdf->MultiCell(49, 0, '<font face="cid0cs">货物已寄递标识</font><br>Goods Delivery Concerns Identified' , 1, 'C', 0, 1, '', '', true, 0, 1);
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function UKOverseas($sales_order_ids)
	{
		set_time_limit(0);
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(3, 3, 3);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 1);
		$pdf->SetLanguageArray($l);
		$columns = array(
			'sales_order_customer_info.*',
			'sales_order.*',
		);
		$sales_order = Sales_Order::find('sales_order.id in (?) and (sales_order.handle_status=? or sales_order.handle_status=?)', $sales_order_ids, Q::ini('custom_flag/sales_order_handle_status/assigned/value'), Q::ini('custom_flag/sales_order_handle_status/printed_address/value'))
			->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
			->setColumns($columns)->asArray()->getAll();
		foreach ($sales_order as $so)
		{
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'BY_GB_Line.jpg', '', '', 70, 15, 'JPG', '', '', true, 300, 'R', false, false, 0, false, false, false);
			$address = $so['fullname'] . "\n";
			$address .= ($so['street1']) ? ($so['street1'] . "\n") : '';
			$address .= ($so['street2']) ? ($so['street2'] . "\n") : '';
			$address .= $so['city'] . "\n";
			$address .= $so['state'] . "\n";
			$address .= $so['zip'] . "\n";
			$address .= $so['country'] . "\n";
			$address .= ($so['phone']) ? ($so['phone'] . "\n") : '';
			$pdf->Ln(18);
			$pdf->SetFont('freeserif', 'B', 10);
			$pdf->MultiCell(94, '', $address, 0, 'L', 0, 1, 2, '', true);
			$pdf->Ln(3);
			$pdf->setFont('droidsansfallback', 'B', 10);
			$pdf->write1DBarcode($so['number'], 'C128', '', '', 94, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');			
		}
		return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
	}
	
	static function RU_Package($sales_order_id)
	{
		set_time_limit(0);
		if ($sales_order_id)
		{
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
				'sales_order_customer_info.*',
				'sales_order.*',
				'shop.gift_card',
				'country.code as country_code',
				'shipping_method.name as shipping_method_name'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
				->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
				->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'number as product_number, declared_name_en, declared_value', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$declared_value = 0;
			foreach ($sales_order_item as $i)
			{
				$declared_value += $i['declared_value'];
			}
			$declared_value = ($declared_value > 20) ? 19.9 : $declared_value;
			if (substr($sales_order['zip'], 0, 1) <= 4)
			{
				$zone = substr($sales_order['zip'], 0, 1);
			}
			elseif (substr($sales_order['zip'], 0, 2) != 63 && substr($sales_order['zip'], 0, 3) < 642)
			{
				$zone = 4;
			}
			else
			{
				$zone = 6;
			}
			$address = "To: ";
			$address .= $sales_order['fullname'] . "\n      ";
			$address .= $sales_order['street1'] ? ($sales_order['street1'] . "\n      ") : '';
			$address .= $sales_order['street2'] ? ($sales_order['street2'] . "\n      ") : '';
			$address .= $sales_order['state'] . ',' . $sales_order['city'] . "\n      ";
			$address .= $sales_order['country'] . "\n";
			$address .= $sales_order['zip'] ? ('ZIP: ' . $sales_order['zip'] . "              ") : '';
			$address .= $sales_order['phone'] ? ('Tel: ' . $sales_order['phone'] . "\n") : '';
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 5, 25, 8, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 12);
			$pdf->MultiCell('', 8, '<font face="cid0cs">航空</font><br>Small packet<br>BY AIR', 1, 'C', 0, 0, '', '', true, 0, true, true);
			$pdf->MultiCell('', 8, 'RU 001', 0, 'C', 0, 1, 60, 3, false);
			$pdf->SetFont('cid0cs', '', 10);
			$pdf->MultiCell(94, 8, '协议客户：23010104577000', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$pdf->SetFont('helvetica', '', 9);
			$pdf->MultiCell(86, 15, 'FROM: NO.7 TIANCHI ROAD PINGFANG DISTRICT' . "\n" . '               HAERBIN CITY HEILONGJIANG STATE CHINA' . "\n" . 'Zip:528000                                Tel: 13632426510', 1, 'L', 0, 0, '', '', true, 0, false, true, 15, 'M');
			$pdf->SetFont('times', '', 6);
			$pdf->MultiCell(8, 7, 'ZONE', 1, 'C', 0, 1, '', '', true, 0, false, true, 7, 'M');
			$pdf->MultiCell(86, 8, '', 0, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(8, 8, $zone, 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 1, 'L', 0, 1, '', '', true, 0, false, true);
			$pdf->SetFont('cid0cs', '', 10);
			$pdf->MultiCell(94, 8, '退件单位： 哈尔滨国际小包收寄中心', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$y = $pdf->GetY();
			$pdf->MultiCell(94, 15, '', 1, 'L', 0, 1, '', '', true, 0, false, true, 15, 'M');
			$pdf->write1DBarcode($sales_order['tracking_number'] ? $sales_order['tracking_number'] : $sales_order['number'], 'C128', 20, $y+2, 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			$pdf->Ln(9);
			$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
			$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
			$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
			$pdf->AddPage();
			$pdf->SetCellMargins(0, 0, 0, 0);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->MultiCell(60, '', '<font face="cid0cs">报关签条<\font><br><font face="helvetica">CUSTOMS DECLARATION</font>', 0, 'L', 0, 0, '', '', true, 0, 1);
			$pdf->SetFont('cid0cs', '', 8);
			$pdf->MultiCell(34, '', '邮 2113', 0, 'R', 0, 1, '', '', true, 0, false, true, 9, 'B');
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(60, '', '<font face="cid0cs">可以径行开拆</font><br>May be opened officially', 0, 'L', 0, 0, '', '', true, 0, 1);
			$pdf->SetFont('times', 'B', 12);
			$pdf->MultiCell(34, 8, 'CN22', 0, 'R', 0, 1, '', '', true);
			$pdf->SetFont('helvetica', '', 9);
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 20.5, 25, 7, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->MultiCell(94, '', '<font face="cid0cs">请先阅读背面的注意事项</font><br>See instructions on the back', 1, 'R', 0, 1, '', '', true, 0, 1);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(40, 14, '<font face="cid0cs">邮件种类(在适当的文字前划"√")</font><br>Calegory of item. Tick as appropriate', 1, 'L', 0, 0, '', '', true, 0, 1, true, 14, 'M');
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(19, 7, '<font face="cid0cs">礼品</font><br>Gift', 1, 'C', 0, 0, '', '', true, 0, 1);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(25, 7, '<font face="cid0cs">商品货样</font><br>Commercial sample', 1, 'C', 0, 1, '', '', true, 0, 1);
			$pdf->MultiCell(40, 7, '', 0, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(19, 7, '<font face="cid0cs">文件</font><br>Documents', 1, 'C', 0, 0, '', '', true, 0, 1);
			$pdf->MultiCell(5, 7, '<font face="cid0cs" style="line-height: 7px;">√</font>', 1, 'C', 0, 0, '', '', true, 0, 1, true, 7, 'M');
			$pdf->MultiCell(25, 7, '<font face="cid0cs">其他</font><br>Other', 1, 'C', 0, 1, '', '', true, 0, 1);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(45, 10, '<font face="cid0cs">内件详细名称和数量</font><br>Quantity and detailed detailed description of contents', 1, 'L', 0, 0, '', '', true, 0, 1, true, 10, 'M');
			$pdf->MultiCell(24, 10, '<font face="cid0cs">重量(千克)</font><br>Weight(kg)', 1, 'C', 0, 0, '', '', true, 0, 1, true, 10, 'M');
			$pdf->MultiCell(25, 10, '<font face="cid0cs">价值</font><br>Value', 1, 'C', 0, 1, '', '', true, 0, 1, true, 10, 'M');
			$pdf->MultiCell(45, 5, $sales_order_item[0]['declared_name_en'], 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$weight = ($sales_order['weight']/1000 <= 2) ? $sales_order['weight']/1000 : 1.99;
			$pdf->MultiCell(24, 5, sprintf('%.2f', $weight / $sales_order['product_quantity']), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value / $sales_order['product_quantity']), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(45, 13, '<font face="cid0cs">协调系统税则号列和货物原产国<br>(只对商品邮件填写)</font><br>HS tariff number and country of origin of goods(Frocommercial items only)', 1, 'L', 0, 0, '', '', true, 0, 1);
			$pdf->MultiCell(24, 13, '<font face="cid0cs">总重量</font><br>Total Weight', 1, 'C', 0, 0, '', '', true, 0, 1, true, 13, 'M');
			$pdf->MultiCell(25, 13, '<font face="cid0cs">总价值</font><br>Total Value', 1, 'C', 0, 1, '', '', true, 0, 1, true, 13, 'M');
			$pdf->MultiCell(45, 5, 'China', 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(24, 5, sprintf('%.2f', $weight), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
			$pdf->Ln(1);
			$pdf->MultiCell(94, 0, '<font face="cid0cs">我保证上述申报准确无误，本函件内未装寄法律或邮政和海关规章禁止寄递的任何危险物品</font><br>I,the undersigned,certify that the particulars given in this declaraton are correct and this item does not contain any dangerous articles prohibited by lagislation or by postal or custome regulations', 0, 'L', 0, 1, '', '', true, 0, 1);
			$pdf->Ln(1);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(94, 0, '<font face="cid0cs">寄件人签字</font> Sender\'s signature', 0, 'L', 0, 1, '', '', true, 0, 1);
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		return array('ack' => FAILURE, 'message' => '', 'label' => '');
	}
	
	static function R_RU_Package($sales_order_id)
	{
		set_time_limit(0);
		if ($sales_order_id)
		{
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
				'sales_order_customer_info.*',
				'sales_order.*',
				'shop.gift_card',
				'country.code as country_code',
				'shipping_method.name as shipping_method_name'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
				->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
				->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'number as product_number, declared_name_en, declared_value', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$declared_value = 0;
			foreach ($sales_order_item as $i)
			{
				$declared_value += $i['declared_value'];
			}
			$declared_value = ($declared_value > 20) ? 19.9 : $declared_value;
			if (substr($sales_order['zip'], 0, 1) <= 4)
			{
				$zone = substr($sales_order['zip'], 0, 1);
			}
			elseif (substr($sales_order['zip'], 0, 2) != 63 && substr($sales_order['zip'], 0, 3) < 642)
			{
				$zone = 4;
			}
			else
			{
				$zone = 6;
			}
			$address = "To: ";
			$address .= $sales_order['fullname'] . "\n      ";
			$address .= $sales_order['street1'] ? ($sales_order['street1'] . "\n      ") : '';
			$address .= $sales_order['street2'] ? ($sales_order['street2'] . "\n      ") : '';
			$address .= $sales_order['state'] . ',' . $sales_order['city'] . "\n      ";
			$address .= $sales_order['country'] . "\n";
			$address .= $sales_order['zip'] ? ('ZIP: ' . $sales_order['zip'] . "              ") : '';
			$address .= $sales_order['phone'] ? ('Tel: ' . $sales_order['phone'] . "\n") : '';
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 5, 25, 8, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->SetFont('helvetica', '', 12);
			$pdf->MultiCell('', 8, '<font face="cid0cs">航空</font><br>Small packet<br>BY AIR', 1, 'C', 0, 0, '', '', true, 0, true, true);
			$pdf->MultiCell('', 8, 'RU 001', 0, 'C', 0, 1, 60, 3, false);
			$pdf->SetFont('cid0cs', '', 10);
			$pdf->MultiCell(94, 8, '协议客户：23010104577000', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$pdf->SetFont('helvetica', '', 9);
			$pdf->MultiCell(86, 15, 'FROM: NO.7 TIANCHI ROAD PINGFANG DISTRICT' . "\n" . '               HAERBIN CITY HEILONGJIANG STATE CHINA' . "\n" . 'Zip:528000                                Tel: 13632426510', 1, 'L', 0, 0, '', '', true, 0, false, true, 15, 'M');
			$pdf->SetFont('times', '', 6);
			$pdf->MultiCell(8, 7, 'ZONE', 1, 'C', 0, 1, '', '', true, 0, false, true, 7, 'M');
			$pdf->MultiCell(86, 8, '', 0, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(8, 8, $zone, 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf->SetFont($font, '', 10);
			$pdf->MultiCell(94, '', $address, 1, 'L', 0, 1, '', '', true, 0, false, true);
			$pdf->SetFont('cid0cs', '', 10);
			$pdf->MultiCell(94, 8, '退件单位： 哈尔滨国际小包收寄中心', 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
			$y = $pdf->GetY();
			$pdf->MultiCell(94, 15, '', 1, 'L', 0, 1, '', '', true, 0, false, true, 15, 'M');
			$pdf->write1DBarcode($sales_order['tracking_number'] ? $sales_order['tracking_number'] : $sales_order['number'], 'C128', 20, $y+2, 60, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			$pdf->Ln(9);
			$pdf->MultiCell(47, 0, $sales_order['shop_id'] . '  ' . date('Y-m-d'), 1, 'L', 0, 0, '', '', true);
			$pdf->MultiCell(27, 0, $sales_order['shipping_method_name'], 1, 'R', 0, 0, '', '', true);
			$pdf->MultiCell(20, 0, $sales_order['product_quantity'], 1, 'R', 0, 1, '', '', true);
			$pdf->AddPage();
			$pdf->SetCellMargins(0, 0, 0, 0);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->MultiCell(60, '', '<font face="cid0cs">报关签条<\font><br><font face="times">CUSTOMS DECLARATION</font>', 0, 'L', 0, 0, '', '', true, 0, 1);
			$pdf->SetFont('cid0cs', '', 8);
			$pdf->MultiCell(34, '', '邮 2113', 0, 'R', 0, 1, '', '', true, 0, false, true, 9, 'B');
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(60, '', '<font face="cid0cs">可以径行开拆</font><br>May be opened officially', 0, 'L', 0, 0, '', '', true, 0, 1);
			$pdf->SetFont('times', 'B', 12);
			$pdf->MultiCell(34, 8, 'CN22', 0, 'R', 0, 1, '', '', true);
			$pdf->SetFont('helvetica', '', 9);
			$pdf->Image(Q::ini('custom_system/img_dir') . 'CN_Package.jpg', 4, 20.5, 25, 7, '', '', 'C', false, 300, '', false, false, 0, false, false, false);
			$pdf->MultiCell(94, '', '<font face="cid0cs">请先阅读背面的注意事项</font><br>See instructions on the back', 1, 'R', 0, 1, '', '', true, 0, 1);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(40, 14, '<font face="cid0cs">邮件种类(在适当的文字前划"√")</font><br>Calegory of item. Tick as appropriate', 1, 'L', 0, 0, '', '', true, 0, 1, true, 14, 'M');
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(19, 7, '<font face="cid0cs">礼品</font><br>Gift', 1, 'C', 0, 0, '', '', true, 0, 1);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(25, 7, '<font face="cid0cs">商品货样</font><br>Commercial sample', 1, 'C', 0, 1, '', '', true, 0, 1);
			$pdf->MultiCell(40, 7, '', 0, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(5, 7, '', 1, 'C', 0, 0, '', '', true);
			$pdf->MultiCell(19, 7, '<font face="cid0cs">文件</font><br>Documents', 1, 'C', 0, 0, '', '', true, 0, 1);
			$pdf->MultiCell(5, 7, '<font face="cid0cs" style="line-height: 7px;">√</font>', 1, 'C', 0, 0, '', '', true, 0, 1, true, 7, 'M');
			$pdf->MultiCell(25, 7, '<font face="cid0cs">其他</font><br>Other', 1, 'C', 0, 1, '', '', true, 0, 1);
			$pdf->SetFont('helvetica', '', 7);
			$pdf->MultiCell(45, 10, '<font face="cid0cs">内件详细名称和数量</font><br>Quantity and detailed detailed description of contents', 1, 'L', 0, 0, '', '', true, 0, 1, true, 10, 'M');
			$pdf->MultiCell(24, 10, '<font face="cid0cs">重量(千克)</font><br>Weight(kg)', 1, 'C', 0, 0, '', '', true, 0, 1, true, 10, 'M');
			$pdf->MultiCell(25, 10, '<font face="cid0cs">价值</font><br>Value', 1, 'C', 0, 1, '', '', true, 0, 1, true, 10, 'M');
			$pdf->MultiCell(45, 5, $sales_order_item[0]['declared_name_en'], 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$weight = ($sales_order['weight']/1000 <= 2) ? $sales_order['weight']/1000 : 1.99;
			$pdf->MultiCell(24, 5, sprintf('%.2f', $weight / $sales_order['product_quantity']), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value / $sales_order['product_quantity']), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(45, 13, '<font face="cid0cs">协调系统税则号列和货物原产国<br>(只对商品邮件填写)</font><br>HS tariff number and country of origin of goods(Frocommercial items only)', 1, 'L', 0, 0, '', '', true, 0, 1);
			$pdf->MultiCell(24, 13, '<font face="cid0cs">总重量</font><br>Total Weight', 1, 'C', 0, 0, '', '', true, 0, 1, true, 13, 'M');
			$pdf->MultiCell(25, 13, '<font face="cid0cs">总价值</font><br>Total Value', 1, 'C', 0, 1, '', '', true, 0, 1, true, 13, 'M');
			$pdf->MultiCell(45, 5, 'China', 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(24, 5, sprintf('%.2f', $weight), 1, 'C', 0, 0, '', '', true, 0, false, true, 5, 'M');
			$pdf->MultiCell(25, 5, 'USD ' . sprintf('%.2f', $declared_value), 1, 'C', 0, 1, '', '', true, 0, false, true, 5, 'M');
			$pdf->Ln(1);
			$pdf->MultiCell(94, 0, '<font face="cid0cs">我保证上述申报准确无误，本函件内未装寄法律或邮政和海关规章禁止寄递的任何危险物品</font><br>I,the undersigned,certify that the particulars given in this declaraton are correct and this item does not contain any dangerous articles prohibited by lagislation or by postal or custome regulations', 0, 'L', 0, 1, '', '', true, 0, 1);
			$pdf->Ln(1);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(94, 0, '<font face="cid0cs">寄件人签字</font> Sender\'s signature', 0, 'L', 0, 1, '', '', true, 0, 1);
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		return array('ack' => FAILURE, 'message' => '', 'label' => '');
	}
	
	static function SF_R_NL_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/SF/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card',
					'country.code as country_code',
					'shipping_method.name as shipping_method_name'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
					->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
					->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$address = "Deliver to:\n";
				$address .= $sales_order['fullname'] . "\n";
				$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
				$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
				$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
				$address .= $sales_order['zip'] . ' ' . $sales_order['country'] . "\n";
				$address .= ($sales_order['phone']) ? ('Tel:' . $sales_order['phone'] . "\n") : '';
				$address .= ($sales_order['address_notes']) ? ('Notes: ' . $sales_order['address_notes'] . "\n") : '';
				$font = Helper_BSS_Normal::getPdfAddFont($address);
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->Image(Q::ini('custom_system/img_dir') . 'logo-code.png', '', 3, 50, 17, 'PNG', '', '', true, 300, 'L', false, false, 0, false, false, false);
				$pdf->Image(Q::ini('custom_system/img_dir') . 'logo1.png', '', 3, 42, 17, 'PNG', '', '', true, 300, 'R', false, false, 0, false, false, false);
				$pdf->setFont('times', '', 8);
				$pdf->MultiCell(90, 4, " Sender: H-11940SFT, Postbus 7040,3109AA Schiedam The Netherlands", 0, 'R', 0, 1, '', 22, true);
				$pdf->Image(Q::ini('custom_system/img_dir') . 'return.gif', 3, 30, 10, 10, 'GIF', '', '', true, 300, 'L', false, false, 0, false, false, false);
				$pdf->SetFont('times' , '', 9);
				$pdf->MultiCell(94, '', 'R Registered/recommandé', 0, 'C', 0, 1, '', '', true);
				$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', '', '', 100, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
				$pdf->SetFont('times' , '', 13);
				$pdf->MultiCell(94, '', $sales_order['tracking_number'], 0, 'C', 0, 1, '', '', true);
				$pdf->MultiCell(55, 25, '', 0, 'L', 0, 1, 5, 45, true);
				$pdf->SetFont($font, '', 10);
				$pdf->MultiCell(40, 45, $address, 0, 'L', 0, 1, 55, 45, true);	
				$pdf->Image(Q::ini('custom_system/img_dir') . 'logo-l.png', '', 72, 35, 10, 'PNG', '', '', true, 300, 'L', false, false, 0, false, false, false);
				$pdf->SetFont('times' , 'B', 20);
				$pdf->MultiCell(15, 5, $sales_order['country_code'], 0, 'L', 0, 1, 40, 72, true);
				$pdf->SetFont('times' , '', 10);
				$pdf->MultiCell(48, 5, $sales_order['lsp_number'], 0, 'C', 0, 1, 5, 83, true);
				$pdf->SetFont('times' , '', 10);
				$pdf->MultiCell(94, 5, '[' . Q::ini('custom_api/SF_api_userid') . ']Ref NO:' . $sales_order['number'] . '   ' . date('Y-m-d H:i:s',time()), 0, 'L', 0, 1, '', 92, true);
				$pdf->AddPage();
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->SetFont('times', 'B', 10);
				$pdf->MultiCell(57, 0, "CUSTOMS\nDECLARATION", 0, 'L', 0, 0, '', '', true);
				$pdf->SetFont('times', '', 8);
				$pdf->MultiCell(20, 0, "May be opened\nofficially", 0, 'R', 0, 0, '', '', true);
				$pdf->SetFont('times', 'B', 15);
				$pdf->MultiCell(16, 0, "CN22", 0, 'R', 0, 1, '', '', true);
				$pdf->SetFont('times', 'B', 8);
				$pdf->MultiCell(46, '', 'Important!', 0, 'R', 0, 1, 50, '', true, 0, true, true);
				$pdf->SetFont('times', '', 8);
				$pdf->MultiCell(48, '', 'Designated operator', 0, 'L', 0, 0, '', '', true, 0, true, true);
				$pdf->MultiCell(46, '', 'See Instructions on the back', 0, 'R', 0, 1, '', '', true, 0, true, true);
				$pdf->SetFont('times', '', 9);
				$pdf->MultiCell(94, 1, "", 0, 'L', 0, 1, '', '', true, 0, false, true, 5, 'M');
				$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(38, 0, "Gift", 1, 'L', 0, 0, '', '', true);
				$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(38, 0, "Commercial Sample", 1, 'L', 0, 1, '', '', true);
				$pdf->MultiCell(9, 0, "", 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(38, 0, "Documents", 1, 'L', 0, 0, '', '', true);
				$pdf->MultiCell(9, 0, '<font face="cid0cs">√</font>', 1, 'C', 0, 0, '', '', true, 0, true, true);
				$pdf->MultiCell(38, 0, "Other", 1, 'L', 0, 1, '', '', true);
				$pdf->MultiCell(53, 10, "Quantity and detail\ndescription of contents", 1, 'L', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->MultiCell(20, 10, "Weight\n(in kg)", 1, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
				$pdf->MultiCell(21, 10, "Value", 1, 'C', 0, 1, '', '', true, 0, false, true, 10, 'M');
				$pdf->SetFont('times', 'B', 9);
				$pdf->MultiCell(53, 10, $sales_order_item[0]['declared_name_en'] . '<br>(<font face="cid0cs">' . $sales_order_item[0]['declared_name_cn'] . '</font>)', 1, 'C', 0, 0, '', '', true, 0, true, true);
				$pdf->MultiCell(20, 10, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(21, 10, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
				$pdf->MultiCell(53, 8, 'Total', 1, 'R', 0, 0, '', '', true, 0, false, true, 0, 'M');
				$pdf->MultiCell(20, 8, sprintf('%.3f', $sales_order_item[0]['weight']/1000), 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(21, 8, sprintf('%.2f', ($sales_order['country'] == 'Germany') ? 15 : ($sales_order_item[0]['declared_value'] > 20) ? 20 : $sales_order_item[0]['declared_value']), 1, 'C', 0, 1, '', '', true);
				$pdf->SetFont('times', '', 8);
				$pdf->MultiCell(94, 8, "For commercial items only. If known, HS tariff number and country of origin of goods", 1, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
				$pdf->MultiCell(94, 16, "I, the undersigned, whose name and address are give on the item certify that the particulars given in this declaration are correct and that this item does not contain any dangerous article or article prohibited by legislation or by postal or customs regulations.Date and sender's signature", 1, 'L', 0, 1, '', '', true, 0, false, true, 16, 'M');
				$pdf->SetFont('helvetica', '', 10);
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function YW_CN_Package($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/Ali/value'))
		{
			if ($sales_order['tracking_number'])
			{
				set_time_limit(0);
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
				require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
				$columns = array(
					'sales_order_customer_info.*',
					'sales_order.*',
					'shop.gift_card',
					'country.code as country_code',
					'shipping_method.name as shipping_method_name'
				);
				$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
					->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
					->joinLeft('shop', '', 'shop.id=sales_order.shop_id')
					->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
					->joinLeft('shipping_method', '', 'shipping_method.id=sales_order.shipping_method')
					->setColumns($columns)->asArray()->getOne();
				$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
					->joinLeft('product_basic', 'number as product_number, declared_value, declared_name_cn, declared_name_en, weight', 'product_basic.id=sales_order_item.product_basic_id')
					->asArray()->getAll();
				$fullname = "To: " . $sales_order['fullname'] . "\n";
				$font = Helper_BSS_Normal::getPdfAddFont($fullname);
				$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
				$pdf->SetCreator(PDF_CREATOR);
				$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
				$pdf->SetMargins(3, 3, 3);
				$pdf->SetPrintHeader(false);
				$pdf->SetPrintFooter(false);
				$pdf->SetAutoPageBreak(true, 1);
				$pdf->SetLanguageArray($l);
				$pdf->setCellMargins(0, 0, 0, 0);
				$pdf->AddPage();
				$pdf->Line(0, 1, 100, 1);
				$pdf->setFont('cid0cs', 'B', 15);
				$pdf->MultiCell(90, 1, "发货标签", 0, 'L', 0, 1, '', 1, true);
				$pdf->SetFont('times' , '', 13);
				$pdf->write1DBarcode($sales_order['tracking_number'], 'C128', '', 11, 100, 10, 0.5, array('align' => 'C', 'text' => false, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
				$pdf->MultiCell(80, 5, "Intl Tracking No: " . $sales_order['tracking_number'], 0, 'L', 0, 0, 20, 22, true);
				$pdf->SetFont('times' , '', 13);
				$pdf->Line(0, 30, 100, 30);
				$pdf->SetFont($font, '', 12);
				$pdf->MultiCell(60, 5, $fullname, 0, 'L', 0, 1, '', 32, true);	
				$pdf->MultiCell(20, 5, "Shipping: ", 0, 'L', 0, 0, '', '', true);	
				$pdf->SetFont('cid0cs', '', 12);
				$pdf->MultiCell(40, 5, "中国邮政平常小包+\n", 0, 'L', 0, 1, '', '', true);
				$pdf->SetFont('times' , '', 13);
				$pdf->MultiCell(60, 5, "From: HuangJianWei\n", 0, 'L', 0, 1, '', '', true);
				$pdf->MultiCell(60, 5, "Tel: 0086-13613019361", 0, 'L', 0, 1, '', '', true);
				$pdf->SetFont('times' , 'B', 15);
				$pdf->MultiCell(15, 5, $sales_order['country_code'], 0, 'R', 0, 1, 80, 32, true);
				$pdf->Line(0, 58, 100, 58);
				$pdf->SetFont('times' , '', 13);
				$pdf->write1DBarcode($sales_order['shop_order_number'], 'C128', '', 62, 100, 10, 0.5, array('align' => 'C', 'text' => false, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
				$pdf->MultiCell(80, 5, "Tracking No:" . $sales_order['shop_order_number'], 0, 'L', 0, 0, 23, 73, true);
				$pdf->Line(0, 80, 100, 80);
				$pdf->SetFont('cid0cs' , '', 10);
				$pdf->MultiCell(100, 5, '是否带电池：否', 0, 'L', 0, 1, 0, 82, true);
				$pdf->MultiCell(100, 5, '仓库：广州市白云区云城西路合城装饰材料城东区三街东9号', 0, 'L', 0, 1, 0, '', true);
				return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
			}
			else
			{
				return array('ack' => FAILURE, 'message' => '订单找不到同步追踪号', 'label' => '');
			}
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
	
	static function HK_DHL($sales_order_id)
	{
		$sales_order = Sales_Order::find('id=?', $sales_order_id)->asArray()->getOne();
		if ($sales_order['synchronous_flag'] == Q::ini('custom_flag/sales_order_synchronous_flag/HK/value'))
		{
			set_time_limit(0);
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
			require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
			$columns = array(
				'sales_order_customer_info.*',
				'sales_order.*',
				'country.code as country_code'
			);
			$sales_order = Sales_Order::find('sales_order.id=?', $sales_order_id)
				->joinLeft('sales_order_customer_info', '', 'sales_order_customer_info.sales_order_id=sales_order.id')
				->joinLeft('country', '', 'country.en_name=sales_order_customer_info.country')
				->setColumns($columns)->asArray()->getOne();
			$sales_order_item = Sales_Order_Item::find('sales_order_item.sales_order_id=?', $sales_order['id'])
				->joinLeft('product_basic', 'declared_value,declared_name_en, declared_name_cn, weight', 'product_basic.id=sales_order_item.product_basic_id')
				->asArray()->getAll();
			$address = $sales_order['fullname'] . "\n";
			$address .= ($sales_order['street1']) ? ($sales_order['street1'] . "\n") : '';
			$address .= ($sales_order['street2']) ? ($sales_order['street2'] . "\n") : '';
			$address .= $sales_order['city'] . ',' . $sales_order['state'] . "\n";
			$address .= $sales_order['zip'] . "\n";
			$address .= $sales_order['country'] . "\n";
			$font = Helper_BSS_Normal::getPdfAddFont($address);
			$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(100, 100), true, 'UTF-8', false);
			$pdf->SetCreator(PDF_CREATOR);
			$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
			$pdf->SetMargins(3, 3, 3);
			$pdf->SetPrintHeader(false);
			$pdf->SetPrintFooter(false);
			$pdf->SetAutoPageBreak(true, 1);
			$pdf->SetLanguageArray($l);
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->AddPage();
			if ($sales_order['country_code'] == 'IT')
			{
				$pdf->SetFont('helvetica', '', 12);
				$pdf->MultiCell(94, 8, "", 1, 'C', 0, 1, 3, '', true, 0, false, true, 8, 'M');
				$pdf->SetFont('helvetica', '', 10);
				$pdf->MultiCell(47, 22, "En cas de non remise<br/>prière de retourner à<br/><br/><b>Postfach 2007<br/>36243 Niederaula<br/>ALLEMAGNE</b>", 1, 'L', 0, 0, 3, '', true, 0, true, true, 22, 'M', 22);
				$pdf->SetFont('helvetica', 'B', 12);
				$pdf->MultiCell(47, 6, "Deutsche Post", 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
				$pdf->SetFont('helvetica', '', 10);
				$pdf->MultiCell(47, 15, "Port payé\n60544 Frankfurt\nAllemagne", 1, 'C', 0, 1, 50, '', true, 0, false, true, 15, 'M', 15);
				$pdf->MultiCell(47, 5.65, "Luftpost/Prioritaire", 1, 'C', 0, 1, 50, '', true, 0, false, true, 6, 'M',6);
			}
			elseif ($sales_order['country_code'] == 'DE')
			{
				$pdf->SetFont('helvetica', '', 11);
				$pdf->MultiCell(47, 24, "Wenn unzustellbar,<br/>zurück an<br/><br/><b>Postfach 2007</b><br/>36243 Niederaula", 1, 'L', 0, 0, 3, '', true, 0, true, true, 24, 'M', 24);
				$pdf->SetFont('helvetica', 'B', 12);
				$pdf->MultiCell(47, 6.45, "Deutsche Post", 1, 'C', 0, 1, '', '', true, 0, false, true, 6.25, 'M');
				$pdf->SetFont('helvetica', '', 11);
				$pdf->MultiCell(47, 18, "Entgelt bezahlt\n60544 Frankfurt\n(2378)", 1, 'C', 0, 1, 50, '', true, 0, false, true, 17, 'M', 17);
			}
			else
			{
				$pdf->SetFont('helvetica', '', 15);
				$pdf->MultiCell(94, 8, "PRIORITAIRE", 1, 'C', 0, 1, 3, '', true, 0, false, true, 8, 'M');
				$pdf->SetFont('helvetica', '', 10);
				$pdf->MultiCell(47, 22, "En cas de non remise<br/>prière de retourner à<br/><br/><b>Postfach 2007<br/>36243 Niederaula<br/>ALLEMAGNE</b>", 1, 'L', 0, 0, 3, '', true, 0, true, true, 22, 'M', 22);
				$pdf->SetFont('helvetica', 'B', 12);
				$pdf->MultiCell(47, 6, "Deutsche Post", 1, 'C', 0, 1, '', '', true, 0, false, true, 6, 'M');
				$pdf->SetFont('helvetica', '', 10);
				$pdf->MultiCell(47, 15, "Port payé\n60544 Frankfurt\nAllemagne", 1, 'C', 0, 1, 50, '', true, 0, false, true, 15, 'M', 15);
				$pdf->MultiCell(47, 5.65, "Luftpost/Prioritaire", 1, 'C', 0, 1, 50, '', true, 0, false, true, 6, 'M',6);
			}
			$pdf->Ln(6);
			$pdf->SetFont('times', '', 9);
			$pdf->MultiCell(30, 0, "PACKET\nSTANDARD", 0, 'L', 0, 1, 3, '', true, 0, false, true, '', 'M');
			$pdf->Ln(11);
			$pdf->SetFont($font, '', 11);
			$pdf->MultiCell(94, 0, $address, 0, 'L', 0, 1, 3, '', true, 0, false, true, '', 'M');
			$pdf->AddPage();
			$pdf->setCellMargins(0, 0, 0, 0);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(60, 0, "Customer reference", 0, 'L', 0, 1, 2, '', true);
			$pdf->Ln(1);
			$pdf->SetFont('helvetica', 'B', 10);
			$pdf->write1DBarcode($sales_order['lsp_number'], 'C128', 6, '', 65, 8, 0.38, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'M');
			$pdf->Ln(9);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(94, 0, '<table><tr><td width="85%"><font size="12">CUSTOMS DECLARATION</font></td><td><font size="12">CN22</font></td></tr><tr><td width="85%">Postal Administration(May be opened officiallly)</td><td>Important!</td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true);
			$y = $pdf->GetY();
			$pdf->Line(3, $y, 3, $y+12, '');
			$pdf->Ln(2);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(5, 0, '', 1, 'C', 0, 0, 6, '', true);
			$pdf->MultiCell(33, 0, ' Gift', 0, 'L', 0, 0, '', '', true, 0, true, true);
			$pdf->MultiCell(5, 0, '', 1, 'C', 0, 0, 56, '', true);
			$pdf->MultiCell(51, 0, ' Sample', 0, 'L', 0, 1, '', '', true, 0, true, true);
			$pdf->Line(97, $y, 97, $y+12, '');
			$y = $pdf->GetY();
			$pdf->Ln(2);
			$pdf->MultiCell(5, '', '', 1, 'C', 0, 0, 6, '', true);
			$pdf->MultiCell(35, '', ' Printed Matter', 0, 'L', 0, 0, '', '', true, 0, true, true);
			$pdf->MultiCell(5, '', '<font face="cid0cs">√</font>', 1, 'C', 0, 0, 56, '', true, 0, true, true);
			$pdf->MultiCell(51, '', ' Others(Tick as appropriate)', 0, 'L', 0, 1, '', '', true, 0, true, true);
			$pdf->Ln(1);
			$pdf->SetFont('helvetica', '', 8);
			$pdf->MultiCell(63, 12, '<table><tr><td><font>Detailed description of Contents</font><br/></td></tr><tr><td align="center" valign="middle"><font size="10">' . $sales_order_item[0]['declared_name_en'] . ' x ' . $sales_order_item[0]['quantity'] . '</font></td></tr></table>', 1, 'L', 0, 0, '', '', true, 0, true);
			$pdf->MultiCell(31, 12, '<table><tr><td height="10%"><font>Value</font><br/></td></tr><tr><td align="center" valign="middle"><font size="10">' . sprintf('%.2f', $sales_order_item[0]['declared_value']) . '</font></td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true);
			$pdf->MultiCell(32, 7, '<table><tr><td height="10%"><font>Origin country</font><br/></td></tr><tr><td align="center" valign="middle"><font size="10">CN</font></td></tr></table>', 1, 'L', 0, 0, '', '', true, 0, true);
			$pdf->MultiCell(31, 7, '<table><tr><td height="10%"><font>Total Weight (kg)</font><br/></td></tr><tr><td align="center" valign="middle"><font size="10">' . sprintf('%.3f', $sales_order_item[0]['weight']/1000) . '</font></td></tr></table>', 1, 'L', 0, 0, '', '', true, 0, true);
			$pdf->MultiCell(31, 7, '<table><tr><td height="10%"><font>Total Value</font><br/></td></tr><tr><td align="center" valign="middle"><font size="10">' . sprintf('%.2f', $sales_order_item[0]['declared_value']) . '</font></td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true);
			$pdf->SetFont('times', '', 9);
			$pdf->MultiCell(94, 20, "I, hereby undersigned whose name and address are give on the item certify that the particulars given in the declaration are correct and that this item does not contain any dangerous articles or articles prohibited by legislation or by postal or customs regulations.", 1, 'L', 0, 1, '', '', true, 0, false, true, 22, 'M');
			$pdf->SetFont('helvetica', '', 10);
			$pdf->MultiCell(94, 8, '<table><tr><td width="100%" colspan="2">Date and Sender\'s Signature</td></tr><tr><td  width="60%"><font size="13">' . date("m-d-Y") . '</font></td><td><font size="15">BAO </font><font size="15">  (UO)</font></td></tr></table>', 1, 'L', 0, 1, '', '', true, 0, true);
			return array('ack' => SUCCESS, 'message' => '', 'label' => $pdf->getPDFData());
		}
		else
		{
			return array('ack' => FAILURE, 'message' => '订单未同步', 'label' => '');
		}
	}
}